[css-variables] Custom properties should *not* serialize "exactly as specified"
Open
Nobody has claimed this yet.
css-variables-1
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
Consider this code:
var s = document.body.style;
s.setProperty("--a", "a(");
s.setProperty("--b", "b");
The spec says "Specified values of custom properties must be serialized exactly as specified by the author". That's what Blink does, but it's bad!
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:
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;"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CSS Custom Properties section linked in the issue, then reproduce the shown setProperty and cssText round-trip cases. Compare the described Blink and Firefox behavior and determine the specification change needed so custom properties round-trip without consuming later declarations. Done means the expected serialization behavior is agreed and reflected in the draft.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css
- Domain
- documentation, web-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100