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

make it possible to be module #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

make it possible to be module #49

wants to merge 2 commits into from

Conversation

zba
Copy link

@zba zba commented Dec 18, 2015

in case of use browserify it fail with 'Cannot use 'in' operator to search for 'onhashchange' in undefined' because window is undefined. this patch fixes it.

zba and others added 2 commits December 18, 2015 10:24
in case of use browserify it fail with 'Cannot use 'in' operator to search for 'onhashchange' in undefined' because window is undefined. this patch fixes  it.
@Krinkle
Copy link

Krinkle commented Dec 18, 2015

Maybe it should use window instead?

Anything using Function for evaluating code to global "this" is imho sufficiently far way from any responsible coding standard that I can't consider it.

Perhaps it makes more sense to simply pass window here since this jQuery plugin has no sensible use case outside a browser environment (unlike jQuery core, for example).

For comparison, jQuery core settled on the following jquery/jquery#1476:

typeof window !== "undefined" ? window : this

@@ -387,4 +387,4 @@
return self;
})();

})(jQuery,this);
})(jQuery,Funtion('return this')());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncaught ReferenceError, I assume this is meant to be Function.

@zba
Copy link
Author

zba commented Sep 16, 2024

Oh, 9years ago.
No, you shall not set it like is your comment, because that shall guarantee, that you not in binded function, correct way is to create function and return "this". I think eval was made to worship linter.

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

Successfully merging this pull request may close these issues.

2 participants