Bug 268742

Summary: cssText wrong escaping
Product: WebKit Reporter: Jozef <32jojo32>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: ahmad.saleem792, karlcow, koivisto, m_dubet, webkit-bug-importer
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 17   
Hardware: Unspecified   
OS: Unspecified   
URL: https://jsfiddle.net/v57r8dt4/

Jozef
Reported 2024-02-05 06:09:38 PST
Run this code in safari and see that the cssText is wrongly escaped const style = document.createElement('style') document.body.append(style) style.sheet.insertRule(`h6 { background: url(/my-image.png), var(--my-image); }`) console.log(style.sheet.cssRules[0].cssText) Output: h6 { background: url(\/my-image\.png), var(--my-image); } Chrome and Firefox outputs: h6 { background: url(/my-image.png), var(--my-image); }
Attachments
Ahmad Saleem
Comment 1 2024-02-05 07:57:44 PST
*** Safari Technology Preview 187 *** "h6 { background: url(\/my-image\.png), var(--my-image); }" *** Chrome Canary 123 *** "h6 { background: url(/my-image.png), var(--my-image); }" *** Firefox Nightly 124 *** "h6 { background: url(/my-image.png), var(--my-image); }" ___ Just wanted to share as of today result. I will share Minibrowesr (WebKit ToT) results later.
Ahmad Saleem
Comment 2 2024-02-05 09:20:14 PST
WebKit ToT (274096@main) same as STP187.
Sam Sneddon [:gsnedders]
Comment 3 2024-02-05 10:53:53 PST
I will note that both outputs are semantically equivalent; have you had this serialisation difference cause problems anywhere?
Sam Sneddon [:gsnedders]
Comment 4 2024-02-05 11:01:46 PST
See also https://github.com/w3c/csswg-drafts/issues/9913 for the spec not matching any existing major browser.
Jozef
Comment 5 2024-02-12 03:31:32 PST
@Sam Sneddon, I don't believe it carries the same semantic meaning. There are actually two backslashes. The raw form is `h6 { background: url(\\/my-image\\.png), var(--my-image); }`. which is not equal to: `h6 { background: url(\/my-image\.png), var(--my-image); }` or `h6 { background: url(/my-image.png), var(--my-image); }`
Radar WebKit Bug Importer
Comment 6 2024-02-12 06:10:13 PST
Note You need to log in before you can comment on or make changes to this bug.