- From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
- Date: Wed, 24 Jan 2024 13:22:13 +0000
- To: public-css-archive@w3.org
Loirooriol has just created a new issue for https://github.com/w3c/csswg-drafts: == [css-variables][cssom] Empty value doesn't round-trip == ```html <!DOCTYPE html> <div style="--a: ; width: var(--a) 100px; height: 100px; background: cyan;"></div> <script> var el = document.querySelector("div"); el.style.setProperty("--a", getComputedStyle(el).getPropertyValue("--a")); </script> ``` I would expect the JS to be no-op as per the round-tripping principle. However, an empty string has a special meaning in `setProperty`: it behaves as `removeProperty`, even though it's valid for custom properties. Some reasonable possibilities: - Don't redirect `setProperty` to `removeProperty` for custom properties, since empty string is a valid value. Authors could explicitly use `removeProperty` if they want to remove. I suspect this may not be web compatible at this point. - Serialize empty values as `" "` instead of `""` so that they can be safely used in `setProperty`, as @prjnt proposed in https://github.com/w3c/csswg-drafts/issues/774#issuecomment-515329876 Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9847 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 24 January 2024 13:22:15 UTC