-
Notifications
You must be signed in to change notification settings - Fork 432
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
Annotator.Util undefined on pages that define a variable called global
#2723
Comments
This might be the same issue as #2397 - that page has detailed a detailed investigation. |
Update - yes, this is indeed the issue described in #2397 - the page defines a variable called |
global
Closed in favor of #2397. |
@judell - That other issue was closed. This is a more generic issue which supersedes that one. I'm afraid my comment didn't make that clear. |
I've created a trello card for this: https://trello.com/c/c4iARNt9/538-bug-annotator-util-undefined-on-pages-that-define-a-variable-called-global |
Modules which assume the existence of a global variable called "global" (which exists in Node) are wrapped by Browserify during the build which normally results in "global" being aliased to "self" or "window" in a browser environment. If code on the page into which H is loaded defines a global variable called "global" however, that gets used instead and this can break such modules. In the case of https://www.civilsprep.com, "global" is a reference to a DOM node for example. This commit fixes the issue by only aliasing "global" (as seen by the module using it) to either "window" or "self" and not to any existing variable called "global". Fixes #2723
Modules which assume the existence of a global variable called "global" (which exists in Node) are wrapped by Browserify during the build which normally results in "global" being aliased to "self" or "window" in a browser environment. If code on the page into which H is loaded defines a global variable called "global" however, that gets used instead and this can break such modules. In the case of https://www.civilsprep.com, "global" is a reference to a DOM node for example. This commit fixes the issue by only aliasing "global" (as seen by the module using it) to either "window" or "self" and not to any existing variable called "global". Fixes #2723
See #2397 (comment) for a minimal repro case of this issue
Launching H via the extension or bookmarklet fails on http://www.thebookseller.com/futurebook/publishing-has-entered-new-and-different-era with a 'cannot read
Util
of undefined` error or variation on that.I'm sure I investigated something similar before that was related to a site defining its own version of 'global' or something similar.
The text was updated successfully, but these errors were encountered: