Skip to content

[css-values-5] Are sibling-count() and sibling-index() math functions? #13978

@kbhomes

Description

@kbhomes

The specification section for tree counting functions isn't explicit about these being math functions or not, other than by omission of the phrase "math function". Is there a definitive answer to whether they are math functions, and why not if they aren't? The behavior seems like it would be the same, other than one case: the serialization of calc(sibling-index()). That would simplify and serialize to sibling-index() as a math function, or remain as calc(sibling-index()) if it was a numeric value / leaf node. I don't believe there are tests disambiguating this currently.

It should be noted that Chrome and Safari both appear to treat these as math functions in their implementations, based on their serialization of calc(sibling-index()).

document.body.style.zIndex = 'calc(sibling-index())';
console.log(document.body.style.zIndex);
// "sibling-index()" in both Chrome and Safari

I'm working on the Firefox implementation for these functions and we're discussing whether to implement them as math functions or not. Implementing them as math functions appears to be simpler than adding support in calc trees and number/integer parsing, and matches Chrome and Safari, but appears to deviate from specification on that serialization case if it isn't a math function.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions