There appears to be an interop mismatch between engines when setting a value with two leading spaces before a var() reference via Typed OM.
Consider:
document.body.attributeStyleMap.set(
'width',
new CSSUnparsedValue([' ', new CSSVariableReferenceValue('--A')])
);
console.log('|' + document.body.style.width + '|');
console.log('|' + document.body.attributeStyleMap.get('width') + '|');
Current behavior differs across engines:
-
Chrome
style.width -> "| var(--A)|"
attributeStyleMap.get('width') -> "| var(--A)|"
-
Safari
style.width -> "| var(--A)|"
attributeStyleMap.get('width') -> "| var(--A)|"
-
Firefox (in progress)
style.width -> "|var(--A)|"
attributeStyleMap.get('width') -> "|var(--A)|"
So for the initial string segment ' ' (two spaces), engines currently:
- preserve it exactly,
- collapse it to a single space,
- or remove it entirely.
For comparison, plain CSSOM string assignment:
document.body.style.width = " var(--A)";
console.log('|' + document.body.style.width + '|');
serializes as:
in all tested browsers.
It seems browsers should consistently normalize leading whitespace in this case, matching CSSOM string parsing/serialization behavior.
There appears to be an interop mismatch between engines when setting a value with two leading spaces before a
var()reference via Typed OM.Consider:
Current behavior differs across engines:
Chrome
style.width->"| var(--A)|"attributeStyleMap.get('width')->"| var(--A)|"Safari
style.width->"| var(--A)|"attributeStyleMap.get('width')->"| var(--A)|"Firefox (in progress)
style.width->"|var(--A)|"attributeStyleMap.get('width')->"|var(--A)|"So for the initial string segment
' '(two spaces), engines currently:For comparison, plain CSSOM string assignment:
serializes as:
"|var(--A)|"in all tested browsers.
It seems browsers should consistently normalize leading whitespace in this case, matching CSSOM string parsing/serialization behavior.