Use String#trim() instead of String#replace()

This commit is contained in:
YUKI Hiroshi 2014-03-31 15:10:51 +09:00
parent a112fffe09
commit 482bab417b
5 changed files with 7 additions and 7 deletions

View File

@ -111,7 +111,7 @@ var TreeStyleTabBookmarksServiceEditable = {
' value=""/>' + ' value=""/>' +
' </menupopup>' + ' </menupopup>' +
' </menulist>' + ' </menulist>' +
'</row>').replace(/^\s*|\s*$/g, '').replace(/>\s+</g, '><'))); '</row>').trim().replace(/>\s+</g, '><')));
range.detach(); range.detach();
document.getElementById('treestyletab-parent-label').setAttribute('value', TreeStyleTabUtils.treeBundle.getString('bookmarkProperty.parent.label')); document.getElementById('treestyletab-parent-label').setAttribute('value', TreeStyleTabUtils.treeBundle.getString('bookmarkProperty.parent.label'));
this.blankItem.setAttribute('label', TreeStyleTabUtils.treeBundle.getString('bookmarkProperty.parent.blank.label')); this.blankItem.setAttribute('label', TreeStyleTabUtils.treeBundle.getString('bookmarkProperty.parent.blank.label'));

View File

@ -312,7 +312,7 @@ var TreeStyleTabWindowHelper = {
return aString return aString
.replace(/\/\*.*\*\//g, '') .replace(/\/\*.*\*\//g, '')
.replace(/\/\/.+$/, '') .replace(/\/\/.+$/, '')
.replace(/^\s+|\s+$/g, ''); .trim();
}); });
}, },
_getFunctionSource : function TSTWH__getFunctionSource(aFunc) _getFunctionSource : function TSTWH__getFunctionSource(aFunc)

View File

@ -14,7 +14,7 @@
* The Original Code is the Tree Style Tab. * The Original Code is the Tree Style Tab.
* *
* The Initial Developer of the Original Code is YUKI "Piro" Hiroshi. * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
* Portions created by the Initial Developer are Copyright (C) 2011-2013 * Portions created by the Initial Developer are Copyright (C) 2011-2014
* the Initial Developer. All Rights Reserved. * the Initial Developer. All Rights Reserved.
* *
* Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com> * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com>
@ -457,7 +457,7 @@ FullTooltipManager.prototype = {
for (let i = 0, maxi = aExtraLabels.length; i < maxi; i++) for (let i = 0, maxi = aExtraLabels.length; i < maxi; i++)
{ {
let label = aExtraLabels[i]; let label = aExtraLabels[i];
label = label.replace(/^\s+|\s+$/g, ''); label = label.trim();
if (!label) if (!label)
continue; continue;
root.appendChild(this.document.createElement('description')) root.appendChild(this.document.createElement('description'))

View File

@ -1261,7 +1261,7 @@ catch(e) {
case 'text/unicode': case 'text/unicode':
case 'text/plain': case 'text/plain':
case 'text/x-moz-text-internal': case 'text/x-moz-text-internal':
return [aData.replace(/^\s+|\s+$/g, '')]; return [aData.trim()];
case 'text/x-moz-url': case 'text/x-moz-url':
return [((aData instanceof Ci.nsISupportsString) ? aData.toString() : aData) return [((aData instanceof Ci.nsISupportsString) ? aData.toString() : aData)

View File

@ -269,7 +269,7 @@ TreeStyleTabWindow.prototype = {
shouldOpenSearchResultAsChild : function TSTWindow_shouldOpenSearchResultAsChild(aTerm) shouldOpenSearchResultAsChild : function TSTWindow_shouldOpenSearchResultAsChild(aTerm)
{ {
aTerm = aTerm.replace(/^\s+|\s+$/g, ''); aTerm = aTerm.trim();
var mode = utils.getTreePref('autoAttach.searchResult'); var mode = utils.getTreePref('autoAttach.searchResult');
if (mode == this.kSEARCH_RESULT_ATTACH_ALWAYS) { if (mode == this.kSEARCH_RESULT_ATTACH_ALWAYS) {
@ -280,7 +280,7 @@ TreeStyleTabWindow.prototype = {
} }
var selection = this.window.getBrowserSelection(); var selection = this.window.getBrowserSelection();
return selection.replace(/^\s+|\s+$/g, '') == aTerm; return selection.trim() == aTerm;
}, },
kSEARCH_RESULT_DO_NOT_ATTACH : 0, kSEARCH_RESULT_DO_NOT_ATTACH : 0,
kSEARCH_RESULT_ATTACH_IF_SELECTED : 1, kSEARCH_RESULT_ATTACH_IF_SELECTED : 1,