diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-04-20 03:09:25 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-04-24 16:14:29 +0200 |
commit | 82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 (patch) | |
tree | 965f6eb89b84d65a62b49008fd972c004832ccd1 /node_modules/when/es6-shim/Promise.js | |
parent | e6e0cbc387c2a77b48e4065c229daa65bf1aa0fa (diff) |
Reorganize module loading.
We now use webpack instead of SystemJS, effectively bundling modules
into one file (plus commons chunks) for every entry point. This results
in a much smaller extension size (almost half). Furthermore we use
yarn/npm even for extension run-time dependencies. This relieves us
from manually vendoring and building dependencies. It's also easier to
understand for new developers familiar with node.
Diffstat (limited to 'node_modules/when/es6-shim/Promise.js')
-rw-r--r-- | node_modules/when/es6-shim/Promise.js | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/node_modules/when/es6-shim/Promise.js b/node_modules/when/es6-shim/Promise.js index 4441fde2b..655a3b447 100644 --- a/node_modules/when/es6-shim/Promise.js +++ b/node_modules/when/es6-shim/Promise.js @@ -252,8 +252,8 @@ define(function(require) { } function hasMutationObserver () { - return (typeof MutationObserver === 'function' && MutationObserver) || - (typeof WebKitMutationObserver === 'function' && WebKitMutationObserver); + return (typeof MutationObserver !== 'undefined' && MutationObserver) || + (typeof WebKitMutationObserver !== 'undefined' && WebKitMutationObserver); } function initMutationObserver(MutationObserver) { @@ -1220,6 +1220,28 @@ define(function() { function noop() {} + function hasCustomEvent() { + if(typeof CustomEvent === 'function') { + try { + var ev = new CustomEvent('unhandledRejection'); + return ev instanceof CustomEvent; + } catch (ignoredException) {} + } + return false; + } + + function hasInternetExplorerCustomEvent() { + if(typeof document !== 'undefined' && typeof document.createEvent === 'function') { + try { + // Try to create one event to make sure it's supported + var ev = document.createEvent('CustomEvent'); + ev.initCustomEvent('eventType', false, true, {}); + return true; + } catch (ignoredException) {} + } + return false; + } + function initEmitRejection() { /*global process, self, CustomEvent*/ if(typeof process !== 'undefined' && process !== null @@ -1233,15 +1255,9 @@ define(function() { ? process.emit(type, rejection.value, rejection) : process.emit(type, rejection); }; - } else if(typeof self !== 'undefined' && typeof CustomEvent === 'function') { - return (function(noop, self, CustomEvent) { - var hasCustomEvent = false; - try { - var ev = new CustomEvent('unhandledRejection'); - hasCustomEvent = ev instanceof CustomEvent; - } catch (e) {} - - return !hasCustomEvent ? noop : function(type, rejection) { + } else if(typeof self !== 'undefined' && hasCustomEvent()) { + return (function (self, CustomEvent) { + return function (type, rejection) { var ev = new CustomEvent(type, { detail: { reason: rejection.value, @@ -1253,7 +1269,19 @@ define(function() { return !self.dispatchEvent(ev); }; - }(noop, self, CustomEvent)); + }(self, CustomEvent)); + } else if(typeof self !== 'undefined' && hasInternetExplorerCustomEvent()) { + return (function(self, document) { + return function(type, rejection) { + var ev = document.createEvent('CustomEvent'); + ev.initCustomEvent(type, false, true, { + reason: rejection.value, + key: rejection + }); + + return !self.dispatchEvent(ev); + }; + }(self, document)); } return noop; |