[csswg-drafts] [css-contain] style containment counter scoping clarification (#5175)

vmpstr has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-contain] style containment counter scoping clarification ==
In the css-contain-2 spec under [style containment](https://www.w3.org/TR/css-contain-2/#containment-style) it says the following:
```
The counter-increment and counter-set properties must be
scoped to the element’s sub-tree and create a new counter.
```
with `scoped to the element's subtree` essentially being "pretend that the subtree is the root of the document, excluding the element itself"

Presumably this refers to counter-increment and counter-set properties of the subtree elements. It's unclear where the counter would be created though. To give an example,

```html
<style>
.contained { contain: style }
.increment { counter-increment: n } 
.increment_and_report::before {
  counter-increment: n;
  content: counter(n);
}
</style>

<div class="contained increment">
  <div class="increment_and_report"></div>
  <div class="increment_and_report"></div>
</div>
```
In my understanding from [one of the web platform tests](http://w3c-test.org/css/css-contain/counter-scoping-003.html), is that this should print out
```
1
2
```

Is this a correct expectation?

Note that the increment happens from .increment_and_report::before which isn't a sibling of the other div with the same class (I think). This would mean that the counter is created at at the subtree of .contained element, so both .increment_and_report divs use the same counter. Would this also mean that the counter-increment elements can be arbitrarily deep and still create counters at the root?

Or should the test instead expect
```
1
1
```
(Or be modified to instead increment the value on span rather than span::before)

That is, does scoping really mean just ignore the element and its ancestors and otherwise behave as you normally would if the subtree was the root of the document?



Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5175 using your GitHub account

Received on Friday, 5 June 2020 20:07:25 UTC