Bug 185953
Summary: | cssText serialization doesn't contain properties with "initial" values | ||
---|---|---|---|
Product: | WebKit | Reporter: | Ben Dean <bendean837> |
Component: | CSS | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | ahmad.saleem792, bfulgham, karlcow, koivisto, obrufau, simon.fraser, webkit-bug-importer |
Priority: | P2 | Keywords: | BrowserCompat, InRadar, Regression |
Version: | Safari 11 | ||
Hardware: | Mac | ||
OS: | macOS 10.13 | ||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=69083 | ||
Bug Depends on: | 242775, 248913 | ||
Bug Blocks: | 81737, 190496 |
Ben Dean
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
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
<rdar://problem/97091857>
Oriol Brufau
*** Bug 245105 has been marked as a duplicate of this bug. ***
Oriol Brufau
*** Bug 248442 has been marked as a duplicate of this bug. ***
Oriol Brufau
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
The code skipping implicit initial values was removed in bug 248913.
Oriol Brufau
*** Bug 245104 has been marked as a duplicate of this bug. ***