-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Representing support of events #7545
Comments
Yay events! 🕺 I refactored the MDN events docs 2 years ago and I'm still familiar with the complicated situation. :) To give an overview about MDN/BCD and events, with your example above: "keydown" is an event type fired on multiple targets and so it appears on a few interfaces, like:
"keydown" is defined by an interface called "KeyBoardEvent":
"onkeydown" is an event handler property and it runs into the "mixin problem", so we have:
"onkeydown" is an event handler content attribute.
For your specific scenarios I have some proposals (I might have practiced this already, but surely these aren't enforced guidelines)
As said above, we may want to have I agree all this should be written down in extensive guidelines for events in BCD (and even more so for how to document all this on MDN). I think it comes down to agreeing to some of the more fine grained structures that I've outlined above. The events work we did 2 years ago started some of this, but it seems like it wasn't sufficient enough yet (or it is just very complicated and we should expand and add more clarity to events.) |
In terms of composing the guidelines, it might help to start with some definitions for support on
Then show some examples of oddities and how to represent them across the 3 or 4 corresponding features. (I think the definitions correspond to what @Elchi3 is saying above, except the HTML bit, though I might be missing some subtleties.) |
I’m just leaving a comment for now just to ack this and to say I’m not ignoring it, but it’ll be a while before I can free up some time* to think about it enough to be able to comment usefully. * Lacking any other clear place to let others on the project know, I’ll just note here that my availability is gonna be a bit limited for while — the reason being that my partner and I just had a new baby girl last week (November 25th), and with two other preschool-age young ones at home already, most of my bandwidth right now is going towards time with the kids :) |
Writing up guidelines for what the different types of entries are sounds great, and apart from the The main problem and the real reason I filed this issue is at the very end of my writeup:
Carefully documenting the support for each will not, I think, lead to something that's good enough. Let's take https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition#Browser_compatibility as an example, a case where both kinds of entries exist for most of the events. (Ignore the prefix mess, fixed in #7554.) As a reader, seeing " So what I wonder is whether we should move towards MDN conveying support for an event as a unified entry, with the details being hidden away unless there's something interesting going on. And what representation in BCD would help make that possible? |
Nowadays, this is probably normal, but historically MDN had documentation for both, events and event handlers, as it happened that there was only one and not the other. It still happens, I don't know how often though. We updated the docs, so that both, event and handler, live together in the same reference page tree and now there is a bit of duplication indeed. (the writing guidelines say that event pages need to have a code example using
Possibly. Usually BCD follows MDN structures, so either we get a discussion going how to document events in a unified way on MDN, or we first outline something for BCD that then informs MDN structures? Either way it seems like we should split out this issue and involve MDN. |
Sounds good. What's the right place to raise editorial issues for MDN? |
I talked to Chris and for now it is https://github.com/mdn/sprints/ |
Every now and then something comes up that makes me think we ought to have a way of producing "synthetic" features that group together hierarchically dispersed features (e.g., |
@ddbeck that sounds like it might help with the events situation. Pairing reflected IDL attributes with their content attributes would also be sensible. Beyond that, are you thinking something as large as "flexbox" as one grouped feature? Would this end up with a feature hierarchy for the whole platform? |
Yeah, this is the question that discourages me from putting effort into this. I don't want to have to maintain many hierarchies—it just seems like I ought to be able to query our data across our boundaries. Though maybe spec_urls could help with this sort of thing. |
I think this issue is going to block #8929. The issue is that when demixing
Whether 4 or 5 interfaces, the outcome would be totally unreasonable IMHO. Example: The "volumechange" event is fired in a single place. Because the event doesn't bubble, the only What we'd get in BCD if just demixing this is the existing api.HTMLMediaElement.volumechange_event entry, and then 5 onvolumechange entries in different places. (There's also svg.attributes.events.global.onvolumechange which I think should be removed.) Sorting this out would take a huge effort also involving mdn/content, so I'll file a sibling issue there. |
Created https://github.com/mdn/content/discussions/5898 to stir up trouble over in mdn/content. |
I was noodling on this problem earlier and got to thinking what if I didn't have to respect any of the existing structures, what might I end up with? I was toying with the idea of supposing that events are sort of special and seeing if I could consolidate the interesting characteristics of events. I ended up here before calling it quits:
As you can see, I still don't know what to do with content attributes. But I think this might be a nice way to make sure only record data for the genuinely interesting event targets and interfaces (and we could, if we wanted, automatically duplicate the |
@ddbeck something like that which links together the interesting things about each distinct event sounds promising. Some care would be needed to define what a distinct event is, since there are many events using the same type string, "error" being the most overloaded I believe. We would probably run into tricky cases where the separateness or sameness of two events is a judgement call or has changed over time. But that's the kind of editorial judgement I think is needed for the result to make sense, just presenting all the information is not good enough IMHO. |
On another note, the support of |
Well, it didn't take long before running into such a tricky judgement case. #10837 (comment) describes the "storage" event in IE8 vs. IE9 and later browsers. The event target, event interface and its properties are different, but the event type ("storage") and cause (a storage area was updated) are the same. Here the question wasn't if this is 1 or 2 events, but I expect we'll run into cases like this in abundance if we try to really get the event data right. |
@foolip following up from our discussion earlier, do you have some examples of events I could use to test out actually writing some JSON to the above proposal? A small number of straightforward, messy, and typical events would probably be pretty revealing, as an actual demonstration of the idea. |
Let's take some examples from simple to complicated. Simple non-bubbling eventsThe "toggle" event fired at a <details>
<summary>toggle me</summary>
stuff stuff stuff
</details>
<script>
var details = document.querySelector('details');
details.addEventListener('toggle', console.log);
</script> This event has One can also use a capturing event listener to listen for it on an ancestor of In BCD, these events usually have Simple bubbling eventsLike above but they bubble. The "input" event is an example of this. The interesting difference is that the event handler can be anywhere without being capturing, notably like this: <input type=checkbox>check me
<script>
window.addEventListener('input', console.log);
</script> Events with their own interfacesThere are lots of these, for example the "message" event triggered by self.addEventListener('message', function(event) {
console.assert(event instanceof MessageEvent);
});
self.postMessage('', '*'); In BCD, these additionally have entries for the event interface, api.MessageEvent in this case. Common sources of messiness:
PrefixesBoth event types and event interfaces can be prefixed, and the That's about it. |
I have just stumbled upon another quirky thing with events in BCD. It turns out there are 3 "animationend_event" entries, one in However we end up dealing with the |
I don't have the bandwidth to fix this issue in Q3 still. If it is brought up again for Q4 and voted as important enough, I'm happy to help solving this then, though. |
Thanks @Elchi3, good to know! (Preparing my votes and sock puppets now...) |
Now that we worked through almost all events, the only structure that hasn't been updated is Instead of all the following MDN pages and BCD entries (that would be correct per the IDL)... https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onanimationend ... we should agree on merging this to a single place, but where should that be? |
Suppose we put it on |
I think I'm leaning towards creating single pages (and BCD entries) under GlobalEventHandlers like so: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/animationend_event Such MDN page could then list where the event is available per IDL (Window, Document, HTMLElement, SVGElement, MathMLElement) and the BCD can use partial support if exposure to some interface is wrong or missing. Happy to hear other thoughts. |
As big of a mixin as GlobalEventHandlers is, I still feel that we should at least separate the BCD entries. It feels a little odd to make the decision to demix all of the mixins, but skip over one or two. On an additional note, it's harder for tooling like the mdn-bcd-collector to update a mixin as we would have to add special logic to formulate partial support entries (which would be a significant amount of work for just one mixin). |
(If it requires a change in bcd collector, then it's absolutely a logical breaking change, please consider major version up.) |
I made a content draft PR for an example event that is defined on Feedback please :) |
I think the draft looks good @Elchi3 - I also think for content keeping |
I played this through for two selection events for further illustration.
For |
Well actually, this wouldn't break anything that isn't already broken in the collector. Currently, since the collector de-mixes all mixins, the I just don't feel like keeping |
For illustration, can you post how many entries this would add? My assumption is that it not practical to add so many entries, but looking at it might help me and others to think more about it. |
I ran the |
Thanks for your research! |
I don't think we should always add *_event entries when an on* property is supported on an interface. Often these properties aren't on the interface that is the event target, and sometimes these event handler properties are where no even can be fired at all. The "contextlost" event is a good example of this. The event target can be either a In this case, we should have api.HTMLCanvasElement.contextlost_event and api.OffscreenCanvas.contextlost_event, which probably have different support data. And the various |
* Adapt selectstart/selectionchange events to new event structure Part of #7545. * Update Node.selectstart_event Co-authored-by: Queen Vinyl Da.i'gyu-Kazotetsu <[email protected]>
I think that we've come to a solid conclusion on how to represent event support in BCD. Can we close this issue? |
Yes, I'm very happy with the outcome in BCD, closing now. 👍 |
Understanding and communicating the support of events in implementations is complicated. Taking the "keydown" event an example, there are many different facets of it:
foo_event
should be isn't always clear or consistent. Example:cut_event
vs.oncut
KeyboardEvent
interface?onkeydown
IDL attribute supported, and on which interfaces?GlobalEventHandlers
, but suchEventHandler
attributes are defined on most interfaces inheriting fromEventTarget
.onkeydown
content attributes supported, and on which elements? Both HTML and SVG define event handler content attributes:Unfortunately, all four facets can come apart:
onfoo
IDL attributes being missing (very common)onfoo
is supported despite "foo" never being fired, also happens.Event
and not a more specializedFooEvent
.These situations are generally not handled well in BCD, and because only event interface and event handler IDL attribute can be detected with simple feature detection, it's often come up in #6369.
What I believe we need:
foo_event
entries should be and what they communicate to data consumers.cut_event
andoncut
entries.@Elchi3 @ddbeck @sideshowbarker @vinyldarkscratch
The text was updated successfully, but these errors were encountered: