Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 71a0cba787b4f7869fbeb052cbecf071e76804ba
https://github.com/WebKit/WebKit/commit/71a0cba787b4f7869fbeb052cbecf071e76804ba
Author: Ahmad Saleem <[email protected]>
Date: 2026-10-11 (Sun, 11 Oct 2026)
Changed paths:
A LayoutTests/fast/history/visited-link-in-shadow-root-expected.txt
A LayoutTests/fast/history/visited-link-in-shadow-root.html
M Source/WebCore/dom/VisitedLinkState.cpp
Log Message:
-----------
:visited style is not updated for links inside shadow trees
https://bugs.webkit.org/show_bug.cgi?id=326642
rdar://189380898
Reviewed by Ryosuke Niwa.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
When a link becomes visited, or the visited link store is cleared,
VisitedLinkState::invalidateStyleForLink() and invalidateStyleForAllLinks()
walk the document with descendantsOfType<Element>(document) to find the links
to restyle. That traversal does not enter shadow roots, so links inside web
components kept their stale :link / :visited style until something else
forced a style recalc.
Fix this by walking shadow-including descendants, recursing into each
element's shadow root, the same way CustomElementRegistry does it. Chrome
and Firefox already restyle these links right away.
Test: fast/history/visited-link-in-shadow-root.html
* LayoutTests/fast/history/visited-link-in-shadow-root-expected.txt: Added.
* LayoutTests/fast/history/visited-link-in-shadow-root.html: Added.
* Source/WebCore/dom/VisitedLinkState.cpp:
(WebCore::invalidateStyleForLinksInShadowIncludingDescendants):
(WebCore::VisitedLinkState::invalidateStyleForAllLinks):
(WebCore::VisitedLinkState::invalidateStyleForLink):
Canonical link: https://commits.webkit.org/323396@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications