← Back to release summary

Fix mouse focus for slotted elements in Shadow DOM

Category
DOM
Type
No developer-visible change
Status
In developer trial (Behind a flag) (Chrome 133)
Intent stage
None

Summary

Currently, mouse-triggered event will traverse up to the parent or shadow host to find fallback element to receive mouse focus. This doesn't make sense for slotted content, where we expect the fallback element to receive focus to be the assigned slot, instead of its parent. This is fixed by changing that step to traverse the Flat Tree.

Motivation

The Chromium issue was opened in 2018 and has 9 stars. In the DOM spec for the Dispatch algorithm [1]: "If isActivationEvent is true, event’s bubbles attribute is true, activationTarget is null, and parent has activation behavior, then set activationTarget to parent." The parent is found using the get the parent algorithm [2]: "A node’s get the parent algorithm, given an event, returns the node’s assigned slot, if node is assigned; otherwise node’s parent." [1] https://dom.spec.whatwg.org/#concept-event-dispatch [2] https://dom.spec.whatwg.org/#get-the-parent

Standards & signals

Samples: https://codepen.io/JanMiksovsky/pen/OBjzeY?editors=1000#0

View on chromestatus.com