Skip to content

[css-contain] Style containment for counters #9212

Open
@nt1m

Description

@nt1m

While looking at: https://github.com/web-platform-tests/wpt/blob/efde03a7b7/css/css-contain/counter-scoping-004.html

It seemed to me that this WPT was incorrect, and that Blink & WebKit's behaviors were correct here.

Since ::before (where we read the counter) is inside the style containment tree (it's a tree abiding pseudo element), counter-increment on the scoping element shouldn't have any effect on the counter inside tree.

I believe that is the intention of the spec as well:

https://drafts.csswg.org/css-contain-2/#property-scoped-to-a-sub-tree

If scoped to a sub-tree, it’s the same, except the scoping element itself is counted as "outside" the tree [...] When considering the effects of the scoped property on elements inside the subtree, the element at the base of the subtree is treated as if it was the root of the document.

To me that essentially means we take all the elements inside the subtree excluding the scoping element, and put that in its own document. Meaning the counter should always be "0" where we read the counter, since the counter is never incremented (since the element that increments it is outside of that "document").

@emilio Can you describe what your interpretation was?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Unslotted

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions