• Robert Knight's avatar
    Fix client failing to load on pages that define `self` · 362b4edf
    Robert Knight authored
    Fix client failing to load on pages that define `self` to be something
    other than `window`.
    
    When AnnotatorJS is bundled by browserify, it is first processed by
    browserify-shim* which adds references to a variable called 'global',
    which exists in Node but not the browser. Browserify then processes the
    result and assigns `global` to the value of the first variable from
    ['global', 'self', 'window'] which is already defined.
    
    https://github.com/hypothesis/h/pull/3385 fixed the problem when the
    page defines a variable called 'global' that is not an alias for
    'window' by reducing this list to ['self', 'window']. This still leaves
    pages that define 'self'.
    
    This commit fixes the problem by always making `global` (within CommonJS
    modules) always be assigned the value of `window`.
    
    * browserify-shim deals with the fact that AnnotatorJS 1.2.x is not a
    CommonJS module and exports its entry point as `window.Annotator`.
    362b4edf
Name
Last commit
Last update
.github Loading commit data...
docs Loading commit data...
images Loading commit data...
scripts Loading commit data...
src Loading commit data...
.eslintignore Loading commit data...
.eslintrc Loading commit data...
.gitignore Loading commit data...
.npmignore Loading commit data...
.npmrc Loading commit data...
.travis.yml Loading commit data...
CHANGELOG.md Loading commit data...
CODE_OF_CONDUCT Loading commit data...
Jenkinsfile Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
gulpfile.js Loading commit data...
npm-shrinkwrap.json Loading commit data...
package.json Loading commit data...