WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 185953
cssText serialization doesn't contain properties with "initial" values
https://bugs.webkit.org/show_bug.cgi?id=185953
Summary
cssText serialization doesn't contain properties with "initial" values
Ben Dean
Reported
2018-05-24 11:56:09 PDT
This happens for both CSSStyleDeclaration.cssText and CSSRule.cssText. ``` var styleEl = document.createElement('style'); styleEl.textContent = 'body { width: initial; }' document.head.appendChild(styleEl); console.log(styleEl.sheet.cssRules[0].cssText); ``` Expected:
> "body { width: initial; }"
Got:
> "body { }"
You can try it here at
https://jsfiddle.net/vu434w60/
Thanks!
Attachments
Add attachment
proposed patch, testcase, etc.
Oriol Brufau
Comment 1
2018-09-13 10:13:19 PDT
The cause seems that StyleProperties::asText() in Source/WebCore/css/StyleProperties.cpp has this code: if (propertyID != CSSPropertyCustom && value == "initial" && !CSSProperty::isInheritedProperty(propertyID)) continue; This was added in
https://bugs.webkit.org/show_bug.cgi?id=81737
But it can't simply be removed, the logic to handle serialization of shorthands and longhands needs to be refactored.
Radar WebKit Bug Importer
Comment 2
2022-07-15 13:43:11 PDT
<
rdar://problem/97091857
>
Oriol Brufau
Comment 3
2022-09-23 06:55:32 PDT
***
Bug 245105
has been marked as a duplicate of this bug. ***
Oriol Brufau
Comment 4
2022-11-28 17:27:41 PST
***
Bug 248442
has been marked as a duplicate of this bug. ***
Oriol Brufau
Comment 5
2022-12-07 08:30:08 PST
Testcase in
comment 0
works well now.
Bug 242775
made it so that only implicit 'initial' values would be skipped. For example, this is still wrong: var {style} = document.createElement("div"); style.container = "foo"; style.removeProperty("container-name"); style.cssText; Ideally this should be "container-type: normal;", but given that style.containerType is "initial" in WebKit, then it should be "container-type: initial;". However, it's just empty string. This remaining problem should be fixed by removing implicit flags (
bug 248383
).
Oriol Brufau
Comment 6
2023-02-09 12:26:03 PST
The code skipping implicit initial values was removed in
bug 248913
.
Oriol Brufau
Comment 7
2023-02-09 12:42:22 PST
***
Bug 245104
has been marked as a duplicate of this bug. ***
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