- From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
- Date: Sun, 29 May 2022 17:05:42 +0000
- To: public-css-archive@w3.org
Loirooriol has just created a new issue for https://github.com/w3c/csswg-drafts:
== [css-variables] Custom properties should *not* serialize "exactly as specified" ==
Consider this code:
```js
var s = document.body.style;
s.setProperty("--a", "a(");
s.setProperty("--b", "b");
```
The spec says "Specified values of [custom properties](https://drafts.csswg.org/css-variables/#custom-property) must be serialized exactly as specified by the author". That's what Blink does, but it's bad!
```js
s.getPropertyValue("--a"); // "a("
s.getPropertyValue("--b"); // "b"
s.cssText; // "--a:a(; --b:b;"
s.cssText = s.cssText;
s.getPropertyValue("--a"); // "a(; --b:b;"
s.getPropertyValue("--b"); // ""
s.cssText; // "--a:a(; --b:b;;"
s.cssText = s.cssText;
s.getPropertyValue("--a"); // "a(; --b:b;;"
s.getPropertyValue("--b"); // ""
s.cssText; // "--a:a(; --b:b;;;"
s.cssText = s.cssText;
s.getPropertyValue("--a"); // "a(; --b:b;;;"
s.getPropertyValue("--b"); // ""
s.cssText; // "--a:a(; --b:b;;;;"
```
I think Firefox is better, since it round-trips:
```js
s.getPropertyValue("--a"); // "a()"
s.getPropertyValue("--b"); // "b"
s.cssText; // "--a: a(); --b: b;"
s.cssText = s.cssText;
s.getPropertyValue("--a"); // "a()"
s.getPropertyValue("--b"); // "b"
s.cssText; // "--a: a(); --b: b;" 
```
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7329 using your GitHub account
-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Sunday, 29 May 2022 17:05:44 UTC