Re: [csswg-drafts] [css-pseudo] Add a ::contents pseudo-element (#2406)

Oh there is another point I wanted to make.

I think it might be a lot easier if the descendants *don't* inherit from ::contents. That should get you past a lot of the concerns. Elements are styled according to their location in the DOM, exactly as they are now, and a `::contents` pseudo-element does not affect this.

This approach is consistent with `content: contents`. An example:

```css
span::before {
    color: red;
    content: '(A=' contents ')';
}
span {
    content: none;
}
span::after {
    content: '(B)'
}
<span>still in black</span>
```
In the box tree, the text content of the `<span>` is a child of the `::before`, but it doesn't inherit any style. And of course it's the same approach taken with all the other box fixups which are not visible to the author; e.g. moving blocks out of inlines affects the box tree, but not the styling.

Put another way: almost nothing inherits from `::contents`. I say almost because if you do this:
```css
span::before {
    color: red;
    content: '(A=' contents ')';
}
span {
    content: none;
}
span::contents {
    color: blue;
    border: 1px solid red;
    display: inline list-item;
}
span::after {
    content: '(B)'
}
<span>test</span>
```
Then the ::contents is getting generated content of its own. I think the result here should be: `(A=•test)(B)`, where `(A` is red, `•` is blue, `test` is black, `)` is red, `(B)` is black, and there is a red border around "•test"


-- 
GitHub Notification of comment by faceless2
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2406#issuecomment-581020219 using your GitHub account

Received on Saturday, 1 February 2020 11:20:01 UTC