fixes #189: use dotted member access when --screw-ie8 option given
This commit is contained in:
15
bin/uglifyjs
15
bin/uglifyjs
@@ -114,20 +114,21 @@ if (ARGS.acorn) {
|
|||||||
acorn = require("acorn");
|
acorn = require("acorn");
|
||||||
}
|
}
|
||||||
|
|
||||||
var COMPRESS = getOptions("c", true);
|
var COMPRESS = getOptions("c", true) || {};
|
||||||
var MANGLE = getOptions("m", true);
|
var MANGLE = getOptions("m", true) || {};
|
||||||
var BEAUTIFY = getOptions("b", true);
|
var BEAUTIFY = getOptions("b", true);
|
||||||
|
|
||||||
if (COMPRESS && ARGS.d) {
|
if (ARGS.d) {
|
||||||
COMPRESS.global_defs = getOptions("d");
|
COMPRESS.global_defs = getOptions("d");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MANGLE && ARGS.r) {
|
if (ARGS.screw_ie8) {
|
||||||
MANGLE.except = ARGS.r.replace(/^\s+|\s+$/g).split(/\s*,+\s*/);
|
COMPRESS.screw_ie8 = true;
|
||||||
|
MANGLE.screw_ie8 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MANGLE && ARGS.screw_ie8) {
|
if (ARGS.r) {
|
||||||
MANGLE.screw_ie8 = true;
|
MANGLE.except = ARGS.r.replace(/^\s+|\s+$/g).split(/\s*,+\s*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
var OUTPUT_OPTIONS = {
|
var OUTPUT_OPTIONS = {
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ function Compressor(options, false_by_default) {
|
|||||||
join_vars : !false_by_default,
|
join_vars : !false_by_default,
|
||||||
cascade : !false_by_default,
|
cascade : !false_by_default,
|
||||||
side_effects : !false_by_default,
|
side_effects : !false_by_default,
|
||||||
|
screw_ie8 : false,
|
||||||
|
|
||||||
warnings : true,
|
warnings : true,
|
||||||
global_defs : {}
|
global_defs : {}
|
||||||
@@ -1961,7 +1962,7 @@ merge(Compressor.prototype, {
|
|||||||
var prop = self.property;
|
var prop = self.property;
|
||||||
if (prop instanceof AST_String && compressor.option("properties")) {
|
if (prop instanceof AST_String && compressor.option("properties")) {
|
||||||
prop = prop.getValue();
|
prop = prop.getValue();
|
||||||
if (is_identifier(prop)) {
|
if (is_identifier(prop) || compressor.option("screw_ie8")) {
|
||||||
return make_node(AST_Dot, self, {
|
return make_node(AST_Dot, self, {
|
||||||
expression : self.expression,
|
expression : self.expression,
|
||||||
property : prop
|
property : prop
|
||||||
|
|||||||
@@ -23,3 +23,18 @@ dot_properties: {
|
|||||||
a["if"] = "if";
|
a["if"] = "if";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dot_properties_es5: {
|
||||||
|
options = {
|
||||||
|
properties: true,
|
||||||
|
screw_ie8: true
|
||||||
|
};
|
||||||
|
input: {
|
||||||
|
a["foo"] = "bar";
|
||||||
|
a["if"] = "if";
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
a.foo = "bar";
|
||||||
|
a.if = "if";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user