Compare commits

...

6 Commits

Author SHA1 Message Date
Mihai Bazon
83e0939088 v2.4.15 2014-07-09 18:01:40 +03:00
Mihai Bazon
9798d96e37 Lock source-map to 0.1.34 2014-07-09 18:01:23 +03:00
Mihai Bazon
ac2caf1088 Check for the case an AST_For's init is an EmptyStatement
(lame fix for #503)
2014-07-01 23:10:44 +03:00
Dan Wolff
8511e80f48 Evaluate "foo".length ==> 3 2014-07-01 11:06:51 +03:00
Mihai Bazon
91bc3f1f92 Merge pull request #499 from shinnn/master
Update .travis.yml to pass the test on Travis CI
2014-06-26 09:30:25 +03:00
Shinnosuke Watanabe
8463b48f90 Do not run a test for Node v0.4
Travis CI doesn’t support Node v0.4.

http://docs.travis-ci.com/user/languages/javascript-with-nodejs/#Provide
d-Node.js-Versions
2014-06-26 13:17:59 +09:00
5 changed files with 36 additions and 5 deletions

View File

@@ -1,6 +1,5 @@
language: node_js language: node_js
node_js: node_js:
- "0.4"
- "0.8" - "0.8"
- "0.10" - "0.10"
- "0.11" - "0.11"

View File

@@ -775,6 +775,14 @@ merge(Compressor.prototype, {
if (d && d.constant && d.init) return ev(d.init, compressor); if (d && d.constant && d.init) return ev(d.init, compressor);
throw def; throw def;
}); });
def(AST_Dot, function(compressor){
if (compressor.option("unsafe") && this.property == "length") {
var str = ev(this.expression, compressor);
if (typeof str == "string")
return str.length;
}
throw def;
});
})(function(node, func){ })(function(node, func){
node.DEFMETHOD("_eval", func); node.DEFMETHOD("_eval", func);
}); });
@@ -2349,7 +2357,7 @@ merge(Compressor.prototype, {
return make_node(AST_Dot, self, { return make_node(AST_Dot, self, {
expression : self.expression, expression : self.expression,
property : prop property : prop
}); }).optimize(compressor);
} }
var v = parseFloat(prop); var v = parseFloat(prop);
if (!isNaN(v) && v.toString() == prop) { if (!isNaN(v) && v.toString() == prop) {
@@ -2361,6 +2369,10 @@ merge(Compressor.prototype, {
return self; return self;
}); });
OPT(AST_Dot, function(self, compressor){
return self.evaluate(compressor)[0];
});
function literals_in_boolean_context(self, compressor) { function literals_in_boolean_context(self, compressor) {
if (compressor.option("booleans") && compressor.in_boolean_context()) { if (compressor.option("booleans") && compressor.in_boolean_context()) {
return make_node(AST_True, self); return make_node(AST_True, self);

View File

@@ -656,7 +656,7 @@ function OutputStream(options) {
output.print("for"); output.print("for");
output.space(); output.space();
output.with_parens(function(){ output.with_parens(function(){
if (self.init) { if (self.init && !(self.init instanceof AST_EmptyStatement)) {
if (self.init instanceof AST_Definitions) { if (self.init instanceof AST_Definitions) {
self.init.print(output); self.init.print(output);
} else { } else {

View File

@@ -3,7 +3,7 @@
"description": "JavaScript parser, mangler/compressor and beautifier toolkit", "description": "JavaScript parser, mangler/compressor and beautifier toolkit",
"homepage": "http://lisperator.net/uglifyjs", "homepage": "http://lisperator.net/uglifyjs",
"main": "tools/node.js", "main": "tools/node.js",
"version": "2.4.14", "version": "2.4.15",
"engines": { "node" : ">=0.4.0" }, "engines": { "node" : ">=0.4.0" },
"maintainers": [{ "maintainers": [{
"name": "Mihai Bazon", "name": "Mihai Bazon",
@@ -16,7 +16,7 @@
}, },
"dependencies": { "dependencies": {
"async" : "~0.2.6", "async" : "~0.2.6",
"source-map" : "~0.1.33", "source-map" : "0.1.34",
"optimist" : "~0.3.5", "optimist" : "~0.3.5",
"uglify-to-browserify": "~1.0.0" "uglify-to-browserify": "~1.0.0"
}, },

View File

@@ -52,3 +52,23 @@ dot_properties_es5: {
a[""] = "whitespace"; a[""] = "whitespace";
} }
} }
evaluate_length: {
options = {
properties: true,
unsafe: true,
evaluate: true
};
input: {
a = "foo".length;
a = ("foo" + "bar")["len" + "gth"];
a = b.length;
a = ("foo" + b).length;
}
expect: {
a = 3;
a = 6;
a = b.length;
a = ("foo" + b).length;
}
}