jquery-hashchange icon indicating copy to clipboard operation
jquery-hashchange copied to clipboard

make it possible to be module

Open zba opened this issue 10 years ago • 0 comments

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 avatar Dec 18 '15 03:12 zba

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 https://github.com/jquery/jquery/pull/1476:

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

Krinkle avatar Dec 18 '15 20:12 Krinkle

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.

zba avatar Sep 16 '24 05:09 zba