You might think this must be a joke, well no , this is a partial lie behind the "use strict"; directive. Roots Of The Hack // global "use strict"; function strict() { "use strict"; // top of the function return { // invoked inline withStrict: function(){ return this; // undefined }(), // invoked inline too withoutStrict: Function("return this")() }; } // the test var really = strict(); really.withStrict; // undefined really.withoutStrict; // global, BOOOOM! The Good News I have been blaming since ever the fact that use strict makes impossible to retrieve the real global object ensuring nobody in the closure redefined window or global by accident so that code is more reliable. Well, now we have the possibility to return it again when it's needed for security reasons or to be sure is the right one. // a classic code for Rhino, node, and Web var G = typeof window !== "undefined" ? window : global...
Update It seems I found a valid fix for "strange" regular expressions. I suppose MyMin will be available tomorrow while packed.it has been just updated with last client version. Have fun with packed.it and please tell me if some source cannot be parsed. -------------------------------------- While I was testing every kind of source and CSS with my last creation, packed.it , I found a bug on JSmin logic, partially recoded inside MyMin project as JavaScript minifier (MyMinCSS and MyMinCompressor seem to work perfectly). This bug seems to be present on every version linked in JSmin page . I found this bug parsing jQuery UI + every CSS with my new service but one JavaScript file has one single, simple problem: function(){return /reg exp with this ' char/;} Bye bye JSmin, regexp will be parsed as string and an error will be raised. The problem is reproducible just with a string that contains only this (so a source that begins and end with these 3 chars): /'/ that's a...
Comments
Post a Comment