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;
|
return window.localStorage;
|
||||||
}(this));
|
}(global));
|
||||||
|
|
||||||
function Intercom() {
|
function Intercom() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -54,14 +54,14 @@ function Intercom() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we're in node.js, skip event registration
|
// If we're in node.js, skip event registration
|
||||||
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
if (typeof document === 'undefined') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.attachEvent) {
|
if (document.attachEvent) {
|
||||||
document.attachEvent('onstorage', storageHandler);
|
document.attachEvent('onstorage', storageHandler);
|
||||||
} else {
|
} 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) {
|
Intercom.prototype._onStorageEvent = function(event) {
|
||||||
event = event || window.event;
|
event = event || global.event;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (this._localStorageChanged(event, INDEX_EMIT)) {
|
if (this._localStorageChanged(event, INDEX_EMIT)) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ var Filer = require('../..');
|
||||||
|
|
||||||
var needsCleanup = [];
|
var needsCleanup = [];
|
||||||
if(global.addEventListener) {
|
if(global.addEventListener) {
|
||||||
window.addEventListener('beforeunload', function() {
|
global.addEventListener('beforeunload', function() {
|
||||||
needsCleanup.forEach(function(f) { f(); });
|
needsCleanup.forEach(function(f) { f(); });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue