Merge pull request #238 from humphd/use-global

Use global vs. window for browserify resolution of global object
This commit is contained in:
Alan K 2014-07-15 19:20:56 +02:00
commit 1392bf35aa
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(); });
});
}