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
Prev Previous commit
Use the es5.defineProperty shim
nornagon committed Oct 5, 2017

Verified

This commit was signed with the committer’s verified signature.
citizenmatt Matt Ellis
commit 0da7d15c7241857fc2b853393fb8dd1ab3bbd5d7
16 changes: 6 additions & 10 deletions src/debuggability.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ var getDomain = Promise._getDomain;
var async = Promise._async;
var Warning = require("./errors").Warning;
var util = require("./util");
var es5 = require("./es5");
var ASSERT = require("./assert");
var canAttachTrace = util.canAttachTrace;
var unhandledRejectionHandled;
@@ -154,16 +155,13 @@ var fireDomEvent = (function() {
var event = new CustomEvent("CustomEvent");
util.global.dispatchEvent(event);
return function(name, event) {
var promise = event.promise;
var reason = event.reason;
var eventData = {
detail: event,
cancelable: true
};
Object.defineProperties(eventData, {
promise: { get: function() { return promise; } },
reason: { get: function() { return reason; } }
});
es5.defineProperty(
eventData, "promise", {value: event.promise});
es5.defineProperty(eventData, "reason", {value: event.reason});
var domEvent = new CustomEvent(name.toLowerCase(), eventData);
return !util.global.dispatchEvent(domEvent);
};
@@ -177,10 +175,8 @@ var fireDomEvent = (function() {
cancelable: true
});
domEvent.detail = event;
Object.defineProperties(domEvent, {
promise: { get: function() { return event.promise; } },
reason: { get: function() { return event.reason; } }
});
es5.defineProperty(domEvent, "promise", {value: event.promise});
es5.defineProperty(domEvent, "reason", {value: event.reason});
return !util.global.dispatchEvent(domEvent);
};
} else {