Use global vs. window for browserify resolution of global object, fixes shared watch events in Intercom

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2014-07-15 11:36:53 -04:00
parent 5b521675c4
commit 4d10ba29a9
2 changed files with 5 additions and 5 deletions

View File

@ -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)) {

View File

@ -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(); });
});
}