-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conform to spec when generating PromiseRejectionEvent #1464
Conversation
src/debuggability.js
Outdated
cancelable: true | ||
cancelable: true, | ||
reason: event.reason, | ||
promise: event.promise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to write this as get promise() { return event.promise; }
? I'm unfamiliar with the compilation pipeline for bluebird, and whether that syntax is supported on all the browsers Bluebird targets.
If we wanted to be even more protective, we could do something like:
var reason = event.reason;
var promise = event.promise;
var domEvent = new CustomEvent(name.toLowerCase(), {
detail: event,
cancelable: true,
get reason() { return reason; },
get promise() { return promise; }
})
or the equivalent with Object.defineProperty
Let me know if that's a desirable change & I can update the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bluebird actually targets ES3 browsers too (supports IE7 for example) - on the other hand this branch of code isn't reached on these browsers anyway.
I just realised this doesn't handle the case where CustomEvent isn't defined, will update. |
Updated to use getters. Let me know if I should squash these commits. |
src/debuggability.js
Outdated
promise: event.promise | ||
cancelable: true | ||
}; | ||
Object.defineProperties(eventData, { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (I think!)
so is it supposed to be data property or getters? it's currently data property |
checked the spec and its readonly data.. merging |
Fixes #1447