[csswg-drafts] [css-sizing] Stop preventing pseudo-elements from having a last remembered size? (#11434)

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

== [css-sizing] Stop preventing pseudo-elements from having a last remembered size? ==
https://drafts.csswg.org/css-sizing-4/#last-remembered

> Only elements capable of being [ResizeObserver](https://drafts.csswg.org/resize-observer-1/#resizeobserver) targets can have a [last remembered size](https://drafts.csswg.org/css-sizing-4/#last-remembered).

AFAIK the point of this sentence was to exclude pseudo-elements, since in JS you can't use `ResizeObserver` to observe pseudo-elements.

The thing is, on both Blink and WebKit, `Element` is a superclass of `PseudoElement`, so pseudo-elements are perfectly capable of being `ResizeObserver` targets, it's just that an author doesn't have access to the `PseudoElement`.

So in fact, pseudo-elements can already have a last remembered size on Blink and WebKit.

On Gecko they can't, but Gecko doesn't even use `ResizeObserver` to track the last remembered size, so the restriction seems pointless anyways.

If pseudo-elements need to be excluded it might be because their lifetime is not completely clear, but that's a completely different topic. By itself, I don't think that not being possible `ResizeObserver` targets justifies not having a last remembered size.

```html
<!DOCTYPE html>
<style>
div::before {
  content: "lorem ipsum";
  display: inline-block;
  border: solid cyan;
  contain-intrinsic-size: auto 0px;
}
div.skip-contents::before {
  content-visibility: hidden;
}
</style>
<div class="skip-contents"></div>
<script>
document.body.offsetLeft;
document.querySelector("div").className = "";
requestAnimationFrame(() => requestAnimationFrame(() => {
  document.querySelector("div").className = "skip-contents";
}));
</script>
```

| Gecko | Blink | WebKit |
| - | - | - |
| ![](https://github.com/user-attachments/assets/cbabff1f-0273-49c0-99d2-f4e1abf2a562) | ![](https://github.com/user-attachments/assets/961edbe5-1758-4eaa-8eb8-a7ede46e2937) | ![](https://github.com/user-attachments/assets/38c8d749-304c-4036-867b-a7cb629a6057) |

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


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

Received on Friday, 3 January 2025 21:39:28 UTC