Skip to content

Conversation

@domenic
Copy link
Member

@domenic domenic commented Mar 14, 2020

Needed for fixing jsdom/jsdom#2869 (used in jsdom/jsdom#2884).

Closes #172 by superceding it. I can actually edit this branch.

@domenic
Copy link
Member Author

domenic commented Mar 14, 2020

The code for generating the constants seems really over-complicated, but I guess it is basically a copy and paste of the code for interfaces. I spent five minutes trying to simplify but it got kind of messy, so I won't pursue that for now. If people have ideas though, I'd be interested.

Copy link
Contributor

@ExE-Boss ExE-Boss left a comment

Choose a reason for hiding this comment

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

There is no such thing as Reflect.call in ECMAScript.

There is only Reflect.apply(…).

lib/types.js Outdated
"enumeration",
"interface"
]);
const resolvedTypes = new Set(["callback interface", "dictionary", "enumeration", "interface"]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I made this multi‑line so that when there’s multiple in‑flight PRs that add new types (like #123), they avoid conflicting with each other.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that's a sufficient motivation for making the code more verbose in that way. In general, please do not change project style without opening an issue for discussion.


const argsToReflectCall = argNames.length > 0 ? `, ${argNames.join(", ")}` : "";
this.str += `
let callResult = Reflect.call(X, thisArg${argsToReflectCall});
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no such thing as Reflect.call(…), so this line will throw a TypeError.

I’ve fixed that in #172.

TimothyGu pushed a commit that referenced this pull request Apr 3, 2020
Closes #178 by superseding it.

Co-authored-by: Domenic Denicola <d@domenic.me>
@domenic domenic deleted the callback-interfaces-2 branch April 17, 2020 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants