Skip to content

Commit

Permalink
FF < 48 does not have CustomEvent in workers.
Browse files Browse the repository at this point in the history
Without this commit, trying to listen for global promise events in a
worker on FF < 48 does not work.
  • Loading branch information
lddubeau committed Aug 29, 2016
1 parent 0e261eb commit 1e3502f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/debuggability.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ var fireDomEvent = (function() {
});
return !util.global.dispatchEvent(domEvent);
};
// In Firefox < 48 CustomEvent is not available in workers but
// Event is.
} else if (typeof Event === "function") {
var event = new Event("CustomEvent");
util.global.dispatchEvent(event);
return function(name, event) {
var domEvent = new Event(name.toLowerCase(), {
cancelable: true
});
domEvent.detail = event;
return !util.global.dispatchEvent(domEvent);
};
} else {
var event = document.createEvent("CustomEvent");
event.initCustomEvent("testingtheevent", false, true, {});
Expand Down

0 comments on commit 1e3502f

Please sign in to comment.