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

Missing machinery for associated Event data #1328

Open
keithamus opened this issue Nov 25, 2024 · 1 comment
Open

Missing machinery for associated Event data #1328

keithamus opened this issue Nov 25, 2024 · 1 comment

Comments

@keithamus
Copy link

What is the issue with the DOM Standard?

In whatwg/html#9841 (comment) @annevk and I discussed some of the spec around the CommandEvent as part of command/commandfor. The source attribute on the CommandEvent performs logic to retarget the element based on its currentTarget, however while this works in browsers it doesn't work so well in the spec. To quote the conversation there:

@annevk: How does this work when it's initialized synthetically? There's also a wrapping problem.

@keithamus: I am unsure how to answer this, as far as I know this just kind of works? If the currentTarget is an element and its tree-root is not the same as the document then it'll be retargeted to the tree-root host. Therefore currentTarget won't return elements that cross a shadow boundary. Is this not the correct way to express that in the spec?

@annevk: If the source attribute is initialized to something it can't also have a getter. I'm not really sure how to make this work specification-wise. This would require some kind of internal slot, but since those are not formalized it would currently clash with how event constructors are defined...

What is missing is the ability to have associated event data. @annevk mentioned in a DM:

I have an idea of sorts that I think can work. I used to think we needed IDL stuff for this, but we can do this by defining an internal "extras" map on event objects that we fill with these data members.

Hopefully I've captured this properly, and we have an idea of what needs to happen to proceed.

@annevk
Copy link
Member

annevk commented Nov 25, 2024

Thanks! Yeah, this is a longstanding issue where we don't define the internal layout of event objects and instead pretend you can set their public API somehow. Using an Infra map we can fully define the internal layout in a way that's extensible without needing IDL to generate this internal layout for us.

(And the reason I mention IDL is that I previously thought we'd need IDL for this: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27354#c10. With Infra maps and IDL dictionaries mapping to maps I don't think that's true anymore.)

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

No branches or pull requests

2 participants