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

Conversation

Projects
None yet
3 participants
@nornagon
Contributor

nornagon commented Oct 5, 2017

Fixes #1447

cancelable: true
cancelable: true,
reason: event.reason,
promise: event.promise

This comment has been minimized.

@nornagon

nornagon Oct 5, 2017

Contributor

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

This comment has been minimized.

@benjamingr

benjamingr Oct 5, 2017

Collaborator

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.

@nornagon

This comment has been minimized.

Contributor

nornagon commented Oct 5, 2017

I just realised this doesn't handle the case where CustomEvent isn't defined, will update.

@nornagon

This comment has been minimized.

Contributor

nornagon commented Oct 5, 2017

Updated to use getters. Let me know if I should squash these commits.

promise: event.promise
cancelable: true
};
Object.defineProperties(eventData, {

This comment has been minimized.

@benjamingr

benjamingr Oct 5, 2017

Collaborator

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

This comment has been minimized.

@nornagon

nornagon Oct 5, 2017

Contributor

Done (I think!)

@petkaantonov

This comment has been minimized.

Owner

petkaantonov commented Oct 6, 2017

so is it supposed to be data property or getters? it's currently data property

@petkaantonov

This comment has been minimized.

Owner

petkaantonov commented Oct 6, 2017

checked the spec and its readonly data.. merging

@petkaantonov petkaantonov merged commit b7f2139 into petkaantonov:master Oct 6, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@nornagon nornagon deleted the nornagon:promise-rejection-event branch Oct 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment