Bug 718518. Remove in-tree uses of the nonstandard third argument to String.prototype.replace. r=dcamp,jgriffin,dao,ted,dtownsend

This commit is contained in:
Till Schneidereit 2012-01-18 16:10:39 -05:00
parent a708223dfb
commit 2751128160
7 changed files with 11 additions and 11 deletions

View File

@ -1271,7 +1271,7 @@ InplaceEditor.prototype = {
// Replace spaces with non-breaking spaces. Otherwise setting
// the span's textContent will collapse spaces and the measurement
// will be wrong.
this._measurement.textContent = this.input.value.replace(' ', '\u00a0', 'g');
this._measurement.textContent = this.input.value.replace(/ /g, '\u00a0');
// We add a bit of padding to the end. Should be enough to fit
// any letter that could be typed, otherwise we'll scroll before

View File

@ -648,7 +648,7 @@ let TPS =
.createInstance(CI.nsILocalFile);
if (hh.oscpu.toLowerCase().indexOf('windows') > -1) {
let re = /\/(\w)\/(.*)/;
this.config.testdir = this.config.testdir.replace(re, "$1://$2").replace("/", "\\", "g");
this.config.testdir = this.config.testdir.replace(re, "$1://$2").replace(/\//g, "\\");
}
mozmillfile.initWithPath(this.config.testdir);
mozmillfile.appendRelativePath(testfile);

View File

@ -108,7 +108,7 @@ LightweightThemeConsumer.prototype = {
function _setImage(aElement, aActive, aURL) {
aElement.style.backgroundImage =
(aActive && aURL) ? 'url("' + aURL.replace('"', '\\"', "g") + '")' : "";
(aActive && aURL) ? 'url("' + aURL.replace(/"/g, '\\"') + '")' : "";
}
function _parseRGB(aColorString) {

View File

@ -56,11 +56,11 @@ var expectedResults = {
// "pastetofirst" strips leading newlines
"pastetofirst": testString.replace(/^\n/, '').split(/\n/)[0],
// "replacewithspaces" strips trailing newlines first - bug 432415
"replacewithspaces": testString.replace(/\n$/, '').replace('\n',' ','g'),
"replacewithspaces": testString.replace(/\n$/, '').replace(/\n/g,' '),
// "strip" is pretty straightforward
"strip": testString.replace('\n','','g'),
"strip": testString.replace(/\n/g,''),
// "replacewithcommas" strips leading and trailing newlines first
"replacewithcommas": testString.replace(/^\n/, '').replace(/\n$/, '').replace('\n',',','g'),
"replacewithcommas": testString.replace(/^\n/, '').replace(/\n$/, '').replace(/\n/g,','),
// "stripsurroundingwhitespace" strips all newlines and whitespace around them
"stripsurroundingwhitespace": testString.replace(/\s*\n\s*/g,'')
};

View File

@ -67,7 +67,7 @@ function parseKeyValuePairs(text) {
let [key, value] = [lines[i].substring(0, eq),
lines[i].substring(eq + 1)];
if (key && value)
data[key] = value.replace("\\n", "\n", "g").replace("\\\\", "\\", "g");
data[key] = value.replace(/\\n/g, "\n").replace(/\\\\/g, "\\");
}
}
return data;

View File

@ -148,14 +148,14 @@ function convertHTMLToPlainText(html) {
var input = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
input.data = html.replace("\n", "<br>", "g");
input.data = html.replace(/\n/g, "<br>");
var output = {};
converter.convert("text/html", input, input.data.length, "text/unicode",
output, {});
if (output.value instanceof Ci.nsISupportsString)
return output.value.data.replace("\r\n", "\n", "g");
return output.value.data.replace(/\r\n/g, "\n");
return html;
}

View File

@ -828,8 +828,8 @@ function loadManifestFromRDF(aUri, aStream) {
let byte_string = [String.fromCharCode(byte) for each (byte in bytes)]
.join("");
// Base64 encode
addon.syncGUID = btoa(byte_string).replace('+', '-', 'g')
.replace('/', '_', 'g');
addon.syncGUID = btoa(byte_string).replace(/\+/g, '-')
.replace(/\//g, '_');
return addon;
}