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

Event dispatch/firing should reuse DOM terms better #1713

Closed
domenic opened this issue Aug 25, 2016 · 5 comments
Closed

Event dispatch/firing should reuse DOM terms better #1713

domenic opened this issue Aug 25, 2016 · 5 comments
Assignees
Labels
clarification Standard could be clearer

Comments

@domenic
Copy link
Member

domenic commented Aug 25, 2016

https://html.spec.whatwg.org/#concept-event-fire defines firing an event and dispatching an event, but instead it should just link to the definitions in DOM: https://dom.spec.whatwg.org/#concept-event-fire and https://dom.spec.whatwg.org/#concept-event-dispatch

Things to consider:

  • Everywhere I clicked that uses "fire an event" instead says "fire a trusted event". Per DOM, firing an event always makes it trusted, so we should (a) check if any cases it needs to be untrusted, and adjust those to something different; (b) remove "trusted" from all the call sites, as it is redundant.
  • DOM should probably be adjusted to make it clear that the caller of "fire an event" can specify the interface, and instead of saying as it currently does "with its cancelable attribute initialized to true", it should encourage us to say (as HTML does) "that is cancelable".
  • IMO we should take this opportunity to clean up all redundant "that does not bubble" or "is not cancelable" since those are the defaults anyway. But... that might cause confusion; see <details> 'toggle' simple event bubbling #1533.
  • While doing this we should consider cleaning up as many default actions as we can (Spec still talks about "default actions" for events #805), or at least the trivial ones that say "has no default action".
@domenic domenic added clarification Standard could be clearer good first issue Ideal for someone new to a WHATWG standard or software project labels Aug 25, 2016
@annevk
Copy link
Member

annevk commented Oct 11, 2016

It should encourage us to say (as HTML does) "that is cancelable"

That seems a little weird. Once we have internal slots as a thing, we basically want HTML to set some internal slots, right? I'm not sure why [[cancelable]] and [[bubbles]] should be privileged above all other internal slots and have magic addressing.

I agree with everything else and would like to put some time in some of this as it helps address some issues in DOM too.

@domenic
Copy link
Member Author

domenic commented Oct 11, 2016

I think we don't need to have double-bracket notation to have internal slots. IMO the existing "that is cancelable" is a way of setting the already-existing implicit cancelable internal slot. (Most places would state this as "associated cancelable flag", but I guess DOM does not at the moment.)

I don't feel strongly either way though, and I see you've already made the changes in #1886 in your preferred direction, so I'm happy to go along with that. Will try to review that later today.

@annevk
Copy link
Member

annevk commented Oct 11, 2016

Sure, agreed on the double brackets, but we also have isTrusted, source, etc. Would we turn those into terms of art too?

(And the main reason DOM doesn't define these as concepts at the moment is that I'd much rather have IDL do this automatically as internal slots (whatever the notation). Otherwise each new event basically needs a bunch of boilerplate to define its concepts and all the "automagic" language we have around the constructor would become way more involved or break down.)

@domenic
Copy link
Member Author

domenic commented Oct 11, 2016

We already did for "trusted", I think? And yeah, I can see how events could be a special case given how they have such a generic internal structure/construction algorithm/re-initialization algorithm.

@annevk
Copy link
Member

annevk commented Oct 11, 2016

Well, I'm just holding out with events due to their nature, but once we have automatic internal slots I'd use them everywhere. Not having to define "associated concepts" would be terrific.

HTML does have something specific for trusted indeed although defined by reference to the isTrusted attribute so I'm not sure that's helping much. (And again, there's many more members.)

annevk added a commit to whatwg/dom that referenced this issue Oct 13, 2016
Fixes #187. Follow up work in HTML is tracked in
whatwg/html#1713.
@domenic domenic removed the good first issue Ideal for someone new to a WHATWG standard or software project label Oct 13, 2016
annevk added a commit to whatwg/dom that referenced this issue Oct 14, 2016
Fixes #187. Follow up work in HTML is tracked in whatwg/html#1713.
alice pushed a commit to alice/html that referenced this issue Jan 8, 2019
This aligns firing and dispatching of events with updated terminology in
the DOM Standard. Among the changes:

* A lot less usage of "default action" which isn't really a thing.
  Instead we make use of the return value of the fire and dispatch
  algorithms.
* Instead of saying things bubble or are cancelable we initialize the
  attributes as such.
* We no longer re-state defaults for isTrusted, bubbles, and cancelable,
  as that only leads to confusion when they are *not* re-stated.
* We now use the legacy target override flag rather than supplying a
  named argument.

This fixes whatwg#1713, but plenty of follow up issues remain:

* whatwg#805 for the remainder of "default action" usage
* whatwg#1394 for updating synthetic click events
* whatwg#1887 for removing "fire a simple event" usage
* whatwg#1893 for updating when checkboxes get checked
* whatwg#1900 for figuring out if event dispatch requires more hooks
* whatwg#1912 for revisiting isTrusted usage
* whatwg#1913 for updating synthetic mouse events
* whatwg#1922 for making more events composed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer
Development

No branches or pull requests

2 participants