Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hoist_props does not work with object/array literals #2508

Closed
kzc opened this issue Nov 24, 2017 · 0 comments · Fixed by #2509
Closed

hoist_props does not work with object/array literals #2508

kzc opened this issue Nov 24, 2017 · 0 comments · Fixed by #2509

Comments

@kzc
Copy link
Contributor

kzc commented Nov 24, 2017

Bug report or feature request?
feature

ES5 or ES6+ input?
ES5

Uglify version (uglifyjs -V)
uglify-js 3.1.10

JavaScript input

Split out the ES5 test cases from #2503 (comment)

Object/Array literals ought to work in hoist_props as numbers already do:

$ echo 'var o = { a:1, f:function(x){console.log(x)} }; o.f(o.a);' | bin/uglifyjs --toplevel -c hoist_props,passes=9 -b
console.log(1);
$ echo 'var o = { a:[1], f:function(x){console.log(x)} }; o.f(o.a);' | bin/uglifyjs --toplevel -c hoist_props,passes=9 -b
var o = {
    a: [ 1 ],
    f: function(x) {
        console.log(x);
    }
};

o.f(o.a);
$ echo 'var o = { a:{b:2}, f:function(x){console.log(x)} }; o.f(o.a);' | bin/uglifyjs --toplevel -c hoist_props,passes=9 -b
var o = {
    a: {
        b: 2
    },
    f: function(x) {
        console.log(x);
    }
};

o.f(o.a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants