Re: [csswg-drafts] Add a property to the `CSSPseudoElement` IDL interface to determine if a pseudo element "exists" (#12158)

As long as we all agree that the CSSPseudoElement is returned regardless of whether it is currently "rendered", we could punt on this. That said, I think having a property similar to the [isConnected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) property is better than developers inspecting the computed style which seems like it would impose an additional requirement that we compute `display` to `none` when the pseudo element isn't rendered, and there would be cases where display would compute to none even when the pseudo was otherwise rendered (e.g. author styled to none).

I assume this also means that the object instance returned remains the same for subsequent calls to `pseudo(type)` even if that pseudo isn't currently rendered. E.g.

```html
<style>
.has-before::before { content: "::before"; }
</style>
<script>
const before1 = elem.pseudo('::before');
const before2 = elem.pseudo('::before');
assert_equals(before1, before2);
elem.classList.add('has-before');
const before3 = elem.pseudo('::before');
assert_equals(before2, before3);
</script>
```


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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 24 June 2025 22:06:32 UTC