Re: [csswg-drafts] [css-contain] CQ vs shadow boundaries (#5984)

I totally get the the disconnect between the intention of shadow-DOM and how it has been used. And I agree that tension needs to be addressed at a higher level. It's also pretty clear that the urgency of that conversation is high and increasing. This is not a one-off instance: custom elements have become a popular way to bundle design-system components, and we need to (somehow) address that need in a way that makes more sense.

Setting that aside, I think there is still a difficult tradeoff to consider here - even in relation to third-party code with hidden internals:

> The only two big exceptions to this "shadow DOM doesn't expose internal details" principle are layout and inheritance.

This feature is complicated by the fact that _the purpose of most container queries is to measure layout_ and also sometimes _to query the styles that are being inherited_. That only works if we're measuring the most narrowly relevant context. I'm not convinced that it makes sense to draw this line between 'layout' (which passes through) and 'measuring the layout' (which currently does not). Or between 'property values' (which inherit across the boundary), and 'querying those values' (which we currently disallow).

I also want to acknowledge that there are some pretty decent workarounds here, if we do keep this resolution. Since elements can't query themselves, grid/flex items already require an extra wrapper to act as a measurable container in some cases. Slotted elements would be able to use _the same workaround_ to measure their own available space. With slotted custom elements, the `:host` may often be able to take on that role, without even needing additional elements. It's not an ideal solution in either case, but in practice it seems pretty workable – and a tradeoff we've already had to make for the sake of container queries. 

To summarize: I'm not fully convinced by either the argument that this is essential for maintaining the integrity of Shadow-DOM, or the argument that this is devastating to the entire combined use of these features. It may just be a tradeoff that needs a bit more clarity and discussion.

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


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

Received on Tuesday, 8 March 2022 23:44:18 UTC