Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conform to spec when generating PromiseRejectionEvent #1464

Merged
merged 3 commits into from
Oct 6, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/debuggability.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,17 @@ var fireDomEvent = (function() {
var event = new CustomEvent("CustomEvent");
util.global.dispatchEvent(event);
return function(name, event) {
var domEvent = new CustomEvent(name.toLowerCase(), {
var promise = event.promise;
var reason = event.reason;
var eventData = {
detail: event,
cancelable: true,
reason: event.reason,
promise: event.promise
cancelable: true
};
Object.defineProperties(eventData, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're using this syntax anyway - can you please use the helpers from util that work in ES3 environments for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (I think!)

promise: { get: function() { return promise; } },
reason: { get: function() { return reason; } }
});
var domEvent = new CustomEvent(name.toLowerCase(), eventData);
return !util.global.dispatchEvent(domEvent);
};
// In Firefox < 48 CustomEvent is not available in workers but
Expand All @@ -172,6 +177,10 @@ var fireDomEvent = (function() {
cancelable: true
});
domEvent.detail = event;
Object.defineProperties(domEvent, {
promise: { get: function() { return event.promise; } },
reason: { get: function() { return event.reason; } }
});
return !util.global.dispatchEvent(domEvent);
};
} else {
Expand Down