Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor refactorings to make UglifyJS happy

  • Loading branch information...
commit affb250f5a455353413a86fe1b428a94b2d6fa9b 1 parent 6f85da8
@sergeche sergeche authored
View
2  javascript/actions/wrapWithAbbreviation.js
@@ -85,7 +85,7 @@ emmet.define('wrapWithAbbreviation', function(require, _) {
if (parsedTree) {
var filtersList = filters.composeList(syntax, profile, data[1]);
filters.apply(parsedTree, filtersList, profile);
- return utils.replaceVariables(parsedTree.toString());
+ return utils.replaceVariables(parsedTree.valueOf());
}
return null;
View
2  javascript/core.js
@@ -175,7 +175,7 @@ var emmet = (function(global) {
var filtersList = filters.composeList(syntax, profile, data[1]);
filters.apply(outputTree, filtersList, profile);
- return outputTree.toString();
+ return outputTree.valueOf();
},
/**
View
8 javascript/parsers/abbreviationParser.js
@@ -348,7 +348,7 @@ emmet.define('abbreviationParser', function(require, _) {
* Returns string representation of current node
* @return {String}
*/
- toString: function() {
+ valueOf: function() {
var utils = require('utils');
var start = this.start;
@@ -365,7 +365,7 @@ emmet.define('abbreviationParser', function(require, _) {
var innerContent = _.map(this.children, function(child) {
- return child.toString();
+ return child.valueOf();
}).join('');
content = require('abbreviationUtils').insertChildContent(content, innerContent, {
@@ -374,6 +374,10 @@ emmet.define('abbreviationParser', function(require, _) {
return start + utils.padString(content, this.padding) + end;
},
+
+ toString: function() {
+ return this.valueOf();
+ },
/**
* Check if current node contains children with empty <code>expr</code>
View
2  javascript/parsers/editTree/cssEditTree.js
@@ -379,7 +379,7 @@ emmet.define('cssEditTree', function(require, _) {
* Returns item string representation
* @returns {String}
*/
- toString: function() {
+ valueOf: function() {
return this.name() + this.styleSeparator + this.value() + this.end();
}
});
View
12 javascript/parsers/editTree/editTree.js
@@ -253,7 +253,7 @@ emmet.define('editTree', function(require, _, core) {
* @param {Boolean} isAbsolute
*/
range: function(isAbsolute) {
- return range(isAbsolute ? this.options.offset : 0, this.toString());
+ return range(isAbsolute ? this.options.offset : 0, this.valueOf());
},
/**
@@ -273,6 +273,10 @@ emmet.define('editTree', function(require, _, core) {
* @returns {String}
*/
toString: function() {
+ return this.valueOf();
+ },
+
+ valueOf: function() {
return this.source;
}
};
@@ -374,7 +378,7 @@ emmet.define('editTree', function(require, _, core) {
* @returns {Range}
*/
range: function(isAbsolute) {
- return range(this.namePosition(isAbsolute), this.toString());
+ return range(this.namePosition(isAbsolute), this.valueOf());
},
/**
@@ -409,11 +413,11 @@ emmet.define('editTree', function(require, _, core) {
* @returns {String}
*/
toString: function() {
- return this.name() + this.value();
+ return this.valueOf();
},
valueOf: function() {
- return this.toString();
+ return this.name() + this.value();
}
};
View
2  javascript/parsers/editTree/xmlEditTree.js
@@ -164,7 +164,7 @@ emmet.define('xmlEditTree', function(require, _) {
return r;
},
- toString: function() {
+ valueOf: function() {
return this.name() + this.styleSeparator
+ this.styleQuote + this.value() + this.styleQuote;
}
View
4 javascript/range.js
@@ -187,6 +187,10 @@ emmet.define('range', function(require, _) {
},
toString: function() {
+ return this.valueOf();
+ },
+
+ valueOf: function() {
return '{' + this.start + ', ' + this.length() + '}';
}
};
View
18 javascript/tabStops.js
@@ -145,14 +145,14 @@ emmet.define('tabStops', function(require, _) {
text = this.processText(text, options);
// now, replace all tabstops with placeholders
- var buf = utils.stringBuilder(), lastIx = 0;
+ var buf = '', lastIx = 0;
var tabStops = _.map(marks, function(mark) {
- buf.append(text.substring(lastIx, mark.start));
+ buf += text.substring(lastIx, mark.start);
var pos = buf.length;
var ph = placeholders[mark.group] || '';
- buf.append(ph);
+ buf += ph;
lastIx = mark.end;
return {
@@ -162,10 +162,10 @@ emmet.define('tabStops', function(require, _) {
};
});
- buf.append(text.substring(lastIx));
+ buf += text.substring(lastIx);
return {
- text: buf.toString(),
+ text: buf,
tabstops: _.sortBy(tabStops, 'start')
};
},
@@ -182,7 +182,7 @@ emmet.define('tabStops', function(require, _) {
processText: function(text, options) {
options = _.extend({}, defaultOptions, options);
- var buf = require('utils').stringBuilder();
+ var buf = '';
/** @type StringStream */
var stream = require('stringStream').create(text);
var ch, m, a;
@@ -190,7 +190,7 @@ emmet.define('tabStops', function(require, _) {
while ((ch = stream.next())) {
if (ch == '\\' && !stream.eol()) {
// handle escaped character
- buf.append(options.escape(stream.next()));
+ buf += options.escape(stream.next());
continue;
}
@@ -235,10 +235,10 @@ emmet.define('tabStops', function(require, _) {
}
}
- buf.append(a);
+ buf += a;
}
- return buf.toString();
+ return buf;
},
/**
View
46 javascript/utils.js
@@ -10,43 +10,6 @@ emmet.define('utils', function(require, _) {
*/
var caretPlaceholder = '${0}';
- /**
- * A simple string builder, optimized for faster text concatenation
- * @param {String} value Initial value
- */
- function StringBuilder(value) {
- this._data = [];
- this.length = 0;
-
- if (value)
- this.append(value);
- }
-
- StringBuilder.prototype = {
- /**
- * Append string
- * @param {String} text
- */
- append: function(text) {
- this._data.push(text);
- this.length += text.length;
- },
-
- /**
- * @returns {String}
- */
- toString: function() {
- return this._data.join('');
- },
-
- /**
- * @returns {String}
- */
- valueOf: function() {
- return this.toString();
- }
- };
-
return {
/** @memberOf utils */
reTag: /<\/?[\w:\-]+(?:\s+[\w\-:]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*\s*(\/?)>$/,
@@ -453,15 +416,6 @@ emmet.define('utils', function(require, _) {
},
/**
- * A simple mutable string shim, optimized for faster text concatenation
- * @param {String} value Initial value
- * @returns {StringBuilder}
- */
- stringBuilder: function(value) {
- return new StringBuilder(value);
- },
-
- /**
* Replace substring of <code>str</code> with <code>value</code>
* @param {String} str String where to replace substring
* @param {String} value New substring value
View
2  plugins/codemirror2/editor.js
@@ -274,7 +274,7 @@ emmet.define('cm-editor-proxy', function(require, _) {
}
_.each(keymap, function(commandName, keybinding) {
- keymap, editorProxy.addAction(commandName, keybinding);
+ editorProxy.addAction(commandName, keybinding);
});
return editorProxy;
Please sign in to comment.
Something went wrong with that request. Please try again.