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

Preliminary support for callback interfaces #182

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

TimothyGu
Copy link
Member

@TimothyGu TimothyGu commented Mar 25, 2020

Implemented JS-to-IDL type conversion but not:

Those things are left to more ambitious pull requests in the future.

Fixes jsdom/jsdom#2869.


I've tested this by linking webidl2js in jsdom (also jsdom/jsdom#2919) and it does fix jsdom/jsdom#2869. Some things in this PR are gathered from elsewhere (like my own #123). But others, like union extraction and type distinguishability bits, were written anew, as they are not handled correctly by any of the other open PRs on callback interfaces (#123, #172, #178). This PR should complement with them nicely.

Implemented JS-to-IDL type conversion but not:

- Saving callback context [1]
- Call a user object's operation [2]
- IDL-to-JS type conversion (jsdom#71)
- Legacy callback interface object [3]

Helps fix jsdom/jsdom#2869.

[1]: https://heycam.github.io/webidl/#dfn-callback-context
[2]: https://heycam.github.io/webidl/#call-a-user-objects-operation
[3]: https://heycam.github.io/webidl/#dfn-legacy-callback-interface-object
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

Nice. So #178 or similar would be done on top of this?

} else {
if (!utils.isObject(curArg)) {
throw new TypeError(
\\"Failed to execute 'addEventListener' on 'EventTarget': parameter 2\\" + \\" is not an object\\"
Copy link
Member

Choose a reason for hiding this comment

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

I think you could make this all one string by tweaking the source.

Copy link
Member Author

@TimothyGu TimothyGu Mar 26, 2020

Choose a reason for hiding this comment

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

I'd like to punt on this. This is slightly difficult, considering I'm currently doing

`${errPrefix} + " is not an object"`

and errPrefix can really be anything, string literal or not. This is also not the only place in the snapshot that has something like this.

@TimothyGu
Copy link
Member Author

So #178 or similar would be done on top of this?

Yes.

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.

document.addEventListener lacks support for registering CustomElements as eventListener
3 participants