Bug 307455

Summary: CSS Custom Highlight API incompatible on Flexbox nodes
Product: WebKit Reporter: Zach Leatherman <zachleatherman>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: bfulgham, karlcow, megan_gardner, rik, simon.fraser, thorton, webkit-bug-importer, wenson_hsieh, zalan
Priority: P2 Keywords: InRadar
Version: Safari 26   
Hardware: Mac (Apple Silicon)   
OS: macOS 26   
Bug Depends on:    
Bug Blocks: 307614    
Attachments:
Description Flags
Testcase none

Zach Leatherman
Reported 2026-02-10 11:46:22 PST
Using the Custom Highlight API on a `display: flex` or `display: inline-flex` node doesn’t render the highlighted ranges. e.g. `<div style="display: flex">I want to highlight some text in here</div>` Reproduction: https://codepen.io/zachleat/pen/MYeZYEN fails in Safari 26.2 and Safari Technology Preview Release 236 (WebKit 21625.1.1.19.1). Works as expected in Firefox 147 and Chrome 144. Just for completeness, a link to the Custom Highlight API: https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API
Attachments
Testcase (3.66 KB, text/html)
2026-02-10 12:07 PST, Anthony Ricaud
no flags
Zach Leatherman
Comment 1 2026-02-10 12:04:01 PST
Current workaround is to add an additional child node: `<div style="display: flex"><div>I can reliably highlight text in here</div></div>`
Anthony Ricaud
Comment 2 2026-02-10 12:07:59 PST
Created attachment 478306 [details] Testcase I've adapted Zach's testcase by: - Adding grid and table examples: to check if it was flex specific or a larger issue. It is a larger issue. - Add variants of each with a "real" element: after adding the other cases, I had a hunch it might be related to flex/grid/table creating "anonymous elements" to lay things out. Those variants tend to confirm my hunch (although I'm sure "anonymous elements" ain't the correct term). - Removing inline-flex: With the other examples I added, I felt it was an unnecessary variant to keep. I haven't removed the flex reference from the title of the bug because I wasn't sure what to put instead.
Karl Dubost
Comment 3 2026-02-11 15:34:54 PST
Thanks, Zac and Anthony. Very useful test case.
Radar WebKit Bug Importer
Comment 4 2026-02-11 15:35:13 PST
Karl Dubost
Comment 5 2026-02-11 23:01:57 PST
I have created a WPT test for it. https://github.com/WebKit/WebKit/pull/58456 That I will export to web-platform-test as soon as it has been reviewed.
Note You need to log in before you can comment on or make changes to this bug.