-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
$ being mangled even when reserved #242
Comments
+1 (function($){
var a = $("a");a.a;
var aa = $("a");aa.a;
})($, $$); minified to: !function($){var a=$("a");a.a;var $=$("a");$.$}($,$$); |
colorhook
added a commit
to colorhook/UglifyJS2
that referenced
this issue
Dec 16, 2013
I have found a hack method: Before mangling the source code, find all the custom reserved keywork defined by var except = ['$', 'exports', 'define', 'require'];
var toplevel = UglifyJS.parse(filecontent, {filename: "?", toplevel: null});
//mangle
var $next_mangled = UglifyJS.AST_Scope.prototype.next_mangled;
UglifyJS.AST_Scope.prototype.next_mangled = function(options){
var m = $next_mangled.call(this, options);
while(except.indexOf(m) != -1){
m = $next_mangled.call(this, options);
}
return m;
}
toplevel.figure_out_scope();
toplevel.compute_char_frequency();
toplevel.mangle_names({except: except}); Also created a AST_Scope.DEFMETHOD("next_mangled", function(options){
var ext = this.enclosed;
out: while (true) {
var m = base54(++this.cname);
if (!is_identifier(m)) continue; // skip over "do"
// we must ensure that the mangled name does not shadow a name
// from some parent scope that is referenced in this or in
// inner scopes.
if(options.except.indexOf(m) !== -1){
continue;
}
for (var i = ext.length; --i >= 0;) {
var sym = ext[i];
var name = sym.mangled_name || (sym.unmangleable(options) && sym.name);
if (m == name) continue out;
}
console.log(m);
return m;
}
}); |
mishoo
added a commit
that referenced
this issue
Dec 16, 2013
Closed with PR #371 |
rvanvelzen
pushed a commit
to rvanvelzen/UglifyJS2
that referenced
this issue
Dec 23, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using a jQuery plugin for tagging (https://github.com/daniel-zahariev/jquery-textntags/blob/master/jquery-textntags.js) and uglify is still overriding the $ as a variable even when told not to with the
-r
flag. Noticed from a build script, but manually running the following command duplicates the issue for me.Specifically, the
editorSelectionLength
variable is the one this is happening to (currently line 87). I noticed the issue of this same variable being reassigned within aswitch
statement around line 286 as well.The text was updated successfully, but these errors were encountered: