Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 743a05e255e03131244e433daf3de1afafa8132b
      
https://github.com/WebKit/WebKit/commit/743a05e255e03131244e433daf3de1afafa8132b
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-05-28 (Thu, 28 May 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt
    M Source/WebCore/dom/Document.cpp

  Log Message:
  -----------
  Autofocus does not focus a host element with a delegatesFocus shadow root
https://bugs.webkit.org/show_bug.cgi?id=315722
rdar://178098507

Reviewed by Ryosuke Niwa.

Per spec [1], "If target is not a focusable area, then set target to the
result of getting the focusable area for target."

Document::flushAutofocusCandidates only runs the focusing steps when the
candidate is itself focusable, so a <div autofocus> whose shadow root has
delegatesFocus is dropped even when the shadow tree has a focus delegate.

Treat the host as a focusable area when findFocusDelegateForTarget on its
delegatesFocus shadow root returns a delegate; Element::focus() then
retargets to the delegate as it already does for direct focus() calls.

[1] 
https://html.spec.whatwg.org/multipage/interaction.html#flush-autofocus-candidates

* 
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt:
 Progression
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::flushAutofocusCandidates):

Canonical link: https://commits.webkit.org/314112@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to