Skip to content

Commit

Permalink
release: 3.7.8
Browse files Browse the repository at this point in the history
  • Loading branch information
briancavalier committed Feb 20, 2017
1 parent 0768dd8 commit 5c0a9eb
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 20 deletions.
52 changes: 40 additions & 12 deletions es6-shim/Promise.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 5c0a9eb

Please sign in to comment.