WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 247852
271001
CSSOM serialization unexpectedly expands some shorthand properties
https://bugs.webkit.org/show_bug.cgi?id=271001
Summary
CSSOM serialization unexpectedly expands some shorthand properties
Qianlang Chen
Reported
2024-03-14 13:23:08 PDT
(See also
https://webkit.org/b/75538
and
https://webkit.org/b/73002
, where this bug has been reported and a fix was attempted.) The return values of `CSSRule.cssText` and `CSSStyleDeclaration.cssText` getters expand some shorthand CSS properties, specifically font-related shorthands like `font` or `font-variant`. To reproduce, run this code in Safari inspector's console: s = new CSSStyleSheet(); s.replaceSync('body { font: 12px serif; }'); console.log(s.cssRules[0].cssText); Observe that the output contains all the expanded longhand properties: body { font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 12px; line-height: normal; font-family: serif; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal; } The expected output should just be body { font: 12px serif; } The issue should be associated with how WebKit serializes a CSS declaration. The specs (
https://drafts.csswg.org/cssom-1/#serialize-a-css-declaration-block
), albeit very hard to read, suggest that shorthand properties should not be expanded and replaced with their longhand equivalents.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-03-14 13:23:40 PDT
<
rdar://problem/124635151
>
Karl Dubost
Comment 2
2024-03-25 14:20:53 PDT
With data:text/html,<div id="target" style="font: 12px serif">foo</div> and const target = document.querySelector("#target"); target.style.cssText; On Firefox, Chrome cssText: "font: 12px serif;" On Safari "font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 12px; line-height: normal; font-family: serif; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;"
Karl Dubost
Comment 3
2024-03-25 14:25:22 PDT
I wonder if there's a WPT already covering this.
Ahmad Saleem
Comment 4
2024-04-05 14:55:28 PDT
Might be dupe of
bug 247852
?
Qianlang Chen
Comment 5
2024-04-05 14:56:44 PDT
(In reply to Ahmad Saleem from
comment #4
)
> Might be dupe of
bug 247852
?
Oooh, looks like it!
Karl Dubost
Comment 6
2024-04-07 17:35:31 PDT
*** This bug has been marked as a duplicate of
bug 247852
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug