Skip to content

[cssom-1][css-values-4][css-cascade-5] When should calc() be maintained in specified value serialization? #8290

Description

@weinig

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.css-values-4Current Work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions