WebKit / standards-positions

WebKit's positions on emerging web specifications
https://webkit.org/standards-positions/
254 stars 21 forks source link

Fire toggle events using microtasks #263

Open josepharhar opened 1 year ago

josepharhar commented 1 year ago

WebKittens

@annevk

Title of the spec

Fire toggle events using microtasks

URL to the spec

https://github.com/whatwg/html/pull/9775

URL to the spec's repository

https://github.com/whatwg/html

Issue Tracker URL

No response

Explainer URL

https://github.com/whatwg/html/issues/9046

TAG Design Review URL

none

Mozilla standards-positions issue URL

https://github.com/mozilla/standards-positions/issues/901

WebKit Bugzilla URL

No response

Radar URL

No response

Description

The toggle events for the popover attribute and the details element, as well as the close event for dialog elements, currently post a task to the DOM manipulation task source to fire these events asynchronously. This means that the event could fire before or after the next render, which could lead to flaky rendering for one frame. By using microtasks instead, the event will always fire before the next render. This was suggested in this HTML spec issue: https://github.com/whatwg/html/issues/9046

annevk commented 1 year ago

This doesn't seem problematic given that beforetoggle already fires synchronously, but that also makes me wonder if queueing a microtask is worth it. I've raised this in https://github.com/whatwg/html/issues/9046#issuecomment-1752752447.