Re: [w3ctag/design-reviews] CSS: contain-intrinsic-size: auto, and converting to a shorthand property (#624)

Thank you for your feedback!

> The concept of last remembered size that is introduced here breaks this fundamental assumption, introducing side effects that persist after properties have stopped applying.

`contain-intrinsic-size` only has an effect if we have size containment, so the side effect here is tied to the presence of size containment (whether introduced by `contain` property directly or via something like `content-visibility`). In other words, I claim that the side effect introduced here does not persist after the property has stopped applying -- it's just not the same property, if that makes sense. But that's a bit of a pedantic point. Other than that, you're right that this introduces a state that is captured at a time different from when the property begin applying. 

> Is there any other existing CSS feature that produces lasting side effects in that way?

I'm not aware of anything in CSS that relies on previous sizing like this. However, we do have things like `content-visibility: auto` which depend on element visibility, relying essentially on `IntersectionObserver` timing. There are also things like container queries, which selectively apply different styles depending on the current state / size of elements. It's not the same as `contain-intrincis-size auto`, for sure, but I feel like it falls in a similar bucket of things that aren't exactly side-effect free.

> Have other ways to solve this problem been sufficiently explored that do not change the way CSS works so dramatically?

The piece of data that we want to capture here is the size that really only the UA knows for sure. Script, for example, can get at this size and the advice that we've been giving developers is to use a polyfill of this feature, directly using `ResizeObserver` or `getBoundingClientRect` to set appropriate values of `contain-intrinsic-size` at appropriate times. But in order for us to do this "automatically" in CSS we would need to snapshot this size before we apply size containment and use it at the time that size containment applies. So fundamentally, there is a timing dependency here that I believe is unavoidable.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/624#issuecomment-828597281

Received on Wednesday, 28 April 2021 16:31:15 UTC