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

Inconsistent treatment of globals with mangle_properties() #1313

Open
AshleyScirra opened this issue Oct 3, 2016 · 1 comment
Open

Inconsistent treatment of globals with mangle_properties() #1313

AshleyScirra opened this issue Oct 3, 2016 · 1 comment

Comments

@AshleyScirra
Copy link
Contributor

mangle_properties() will mangle properties on the global object, whereas the rest of UglifyJS does not modify globals. This inconsistency breaks scripts which create globals like so:

window.Foo = {};
Foo.bar = 1;

// is mangled to:
window.q = {}; // mangled property
Foo.r = 1;  // unmangled global

There should be a way to make mangle_properties avoid mangling properties where the left side of the dot is a well-known global alias, i.e. window, self, global.

@AshleyScirra
Copy link
Contributor Author

This is actually pretty complicated. For example localforage does something like this:

(function (e)
{
    e.localforage = {...};
})(window);

It's probably pretty complicated to figure out that it's a global reference there... I guess maybe the solution is just to reserve the property name localforage :-\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants