I am trying to determine if there is there a universal rule for when calc() should be maintained when serializing specified values?
For example, consider the following:
let test = document.createElement("div")
test.style.width = "calc(100px)"
console.log(test.style.width)
In both Safari and Firefox (I have not tested anything else so far), this logs "calc(100px)". (If you were to go and add the element to the DOM and query the computed style, you would get "100px"). So for this property / value at least, calc() seems to be maintained in the specified value serialization.
However, if you take:
let test = document.createElement("div")
test.style.color = "rgb(calc(100), 255, 255)"
console.log(test.style.color)
this logs "rgb(100, 255, 255)", seemingly resolving the calc().
It's possible this is clearly defined somewhere, or perhaps it is up to each individual property and/or value to define, but I have been having trouble finding it.
https://drafts.csswg.org/cssom/#serialize-a-css-component-value makes mention of differentiating between specified and computed / resolved values (calling it out as an issue), but its not clear that CSSOM would be the right spec for defining rules for calc() (though perhaps it would).
(See https://bug-250325-attachments.webkit.org/attachment.cgi?id=464424 for a live testcase)
I am trying to determine if there is there a universal rule for when
calc()should be maintained when serializing specified values?For example, consider the following:
In both Safari and Firefox (I have not tested anything else so far), this logs "calc(100px)". (If you were to go and add the element to the DOM and query the computed style, you would get "100px"). So for this property / value at least, calc() seems to be maintained in the specified value serialization.
However, if you take:
this logs "rgb(100, 255, 255)", seemingly resolving the calc().
It's possible this is clearly defined somewhere, or perhaps it is up to each individual property and/or value to define, but I have been having trouble finding it.
https://drafts.csswg.org/cssom/#serialize-a-css-component-value makes mention of differentiating between specified and computed / resolved values (calling it out as an issue), but its not clear that CSSOM would be the right spec for defining rules for calc() (though perhaps it would).
(See https://bug-250325-attachments.webkit.org/attachment.cgi?id=464424 for a live testcase)