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

if(false) { var define; } overites the global define in IE - nodeAdapter.js #48

Open
duzun opened this issue Nov 13, 2014 · 3 comments
Open

Comments

@duzun
Copy link
Contributor

duzun commented Nov 13, 2014

I had this issue before with IE.
Take a look at this code:

    var x = 10; 
    function a(){ return x; try{}catch(x){} }; 
    alert(a()); // 10 in V8, undefined in IE

In IE (not sure until which version), if a variable is declared anywhere in the scope (inside any block, even a false if), it is available everywhere in that scope, even before its declaration.

Therefore this code overwrites define in environments like IE:

    if (typeof module === 'object' && typeof define !== 'function') {
         var define = function (factory) {
             module.exports = factory(require, exports, module);
         };
    }
@duzun duzun changed the title if(false) { var define; } overites the blobal define in IE - nodeAdapter.js if(false) { var define; } overites the global define in IE - nodeAdapter.js Nov 13, 2014
@szepeviktor
Copy link

If you use ```javascript the code gets highlighted.

@duzun
Copy link
Contributor Author

duzun commented Nov 13, 2014

Thanks for advice, szepeviktor

:-)

duzun added a commit to duzun/umd that referenced this issue Nov 14, 2014
Wrap `define` in a self-invoked function
@tejacques
Copy link

You can use one of these variations of UMD instead:

https://gist.github.com/tejacques/202a8f2d198ddd54a409
https://gist.github.com/wilsonpage/8598603

Instead of defining a var define, it's passed in as a function argument instead.

addyosmani added a commit that referenced this issue Feb 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants