Merge pull request #238 from humphd/use-global
Use global vs. window for browserify resolution of global object
This commit is contained in:
commit
1392bf35aa
|
@ -38,7 +38,7 @@ var localStorage = (function(window) {
|
|||
};
|
||||
}
|
||||
return window.localStorage;
|
||||
}(this));
|
||||
}(global));
|
||||
|
||||
function Intercom() {
|
||||
var self = this;
|
||||
|
@ -54,14 +54,14 @@ function Intercom() {
|
|||
};
|
||||
|
||||
// If we're in node.js, skip event registration
|
||||
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
||||
if (typeof document === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (document.attachEvent) {
|
||||
document.attachEvent('onstorage', storageHandler);
|
||||
} else {
|
||||
window.addEventListener('storage', storageHandler, false);
|
||||
global.addEventListener('storage', storageHandler, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ Intercom.prototype._localStorageChanged = function(event, field) {
|
|||
};
|
||||
|
||||
Intercom.prototype._onStorageEvent = function(event) {
|
||||
event = event || window.event;
|
||||
event = event || global.event;
|
||||
var self = this;
|
||||
|
||||
if (this._localStorageChanged(event, INDEX_EMIT)) {
|
||||
|
|
|
@ -2,7 +2,7 @@ var Filer = require('../..');
|
|||
|
||||
var needsCleanup = [];
|
||||
if(global.addEventListener) {
|
||||
window.addEventListener('beforeunload', function() {
|
||||
global.addEventListener('beforeunload', function() {
|
||||
needsCleanup.forEach(function(f) { f(); });
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue