Re: [csswg-drafts] [css-variables][cssom] Empty value doesn't round-trip (#9847)

I agree that we should change `getProperty()` to serialize an empty custom property to `" "`.

I was at first concerned that this could break things that are depending on the custom property actually being *empty* - CSS usually doesn't care about whitespace, just token separation, but we do have a *few* places that care, like in selectors. But then I remembered that parsing is already specified to strip leading/trailing whitespace, so there's actually no behavior difference between `""` and `" "` as the value.

I do think changing `setProperty()`'s behavior on custom properties would be better, but I suspect it's not web-compatible, and I don't think it's even *possible* to tell the compat impact without making the change and seeing what breaks.

Serializing to other values, like `"/**/"`, might be slightly more technically correct, but is more likely, imo, to break scripts that might `.strip()` the value and test for emptiness.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9847#issuecomment-2358955832 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 18 September 2024 16:44:31 UTC