html icon indicating copy to clipboard operation
html copied to clipboard

details element toggle event should bubble

Open gibson042 opened this issue 3 years ago • 2 comments
trafficstars

https://html.spec.whatwg.org/multipage/interactive-elements.html#the-details-element

Whenever the open attribute is added to or removed from a details element, the user agent must queue an element task on the DOM manipulation task source given then details element that runs the following steps, which are known as the details notification task steps, for this details element:

  1. Fire an event named toggle at the details element.

Because that does not include "with the bubbles attribute initialized to true", the event does not bubble. And because it does not bubble, there is no convenient way to detect when a descendant details element is opened or closed (even though it is possible with general DOM mutation observation). In addition to making certain patterns unnecessarily difficult, this behavior diverges from similar events such as changing an input, select, or textarea element or its selection, resetting or submitting a form, and even clicking any element.

gibson042 avatar Aug 24 '22 17:08 gibson042

there is no convenient way to detect when a descendant details element is opened or closed

Use capturing event listener?

smaug---- avatar Aug 24 '22 23:08 smaug----

That works, but also fails the convenience criterion in many cases because the outside-in traversal order is backwards from defaults (and again, is not necessary for other similar events).

gibson042 avatar Aug 25 '22 07:08 gibson042

@domenic @annevk Is this a wontfix given https://github.com/whatwg/html/issues/8888 ?

nt1m avatar Feb 21 '23 23:02 nt1m