-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-cascade-6] Should the scope proximity calculation be impacted by nesting scopes? #10795
Comments
Thinking through it a bit more, and discussing with @argyleink, I don't really have any reason not to do this. The alternative is falling back on source order, which isn't better than multi-step proximity. And I believe there's no difference between the two approaches above. The distance between two roots will always be equivalent to the additional distance between a subject and ancestor root. So the approach seems straight-forward. So unless there's push back from other implementors (@andruud made the initial change here?), I'm going to propose we resolve on @mdubet's proposal here. Marking this as agenda+ to try and get that resolution. |
@mirisuzanne In other words, this would introduce a dynamic number of cascade criteria (for the first time)? A bit like specificity, but instead of (A,B,C), it's a variable number of components.
Last time this came up, we concluded that: 1) it adds complexity (both for impl and authors' mental model), and 2) it's not useful. Your answer to this question suggests that nothing has changed. Therefore, I do oppose this change, as it seems to (at best) only be about theoretical purity at the expense of other things.
We'd ideally investigate that a little bit before making any moves spec wise. @scope also shipped a long time ago in Blink. I would need to be able to prove that we even can ship such a change without breakage. Otherwise, we might end up with subtly different cascade behaviors forever, which is worse than just aligning on the current spec.
We should minimally first answer the "But why?" with an actual answer, and explain why the more complex behavior is useful after all. |
cc @dshin-moz |
So given something like
and given below rules:
The concern is that the applied FWIW, authors that want this could coax this out by using
|
As for adding a dynamically-sized cascade criteria... I generally agree with @andruud - Concerned about complexity on implementations/authors. Could adding a count of nested |
To flesh that proposal out a bit, we'd have a (consistently) two-part value, including:
In your example, the first rule has a scope of I would be happy with that as an approximation. |
(I said elsewhere that I'd look into the complexity and performance issues re. adding a dynamic number of cascade criteria, but I'm still working on that, so I won't comment on that yet.)
That would be much more acceptable, so +1 from me. I would also argue that it's better for authors to not over-complicate the cascade criteria even more, and outer scopes just adding a flat @mirisuzanne Once, you also believed in the benefit of keeping it simple here:
I still haven't seen an actual reason to change anything here, but I can live with @dshin-moz' proposal in any case. |
I do still think it's worth keeping this simple. I'm just happy to have the conversation - and want to make sure we're getting the right balance. Simple for authors to reason about is more important to me than simple for browsers to track. And I'm curious what makes the most sense to others. |
+1 to cascade order being already complicated enough fwiw. I actually wonder if scope proximity is all that useful to begin with.. |
I've prototyped the original proposal in Blink, and there will be performance regressions if we do this. Not as severe as I feared, but still enough that I think we should strongly consider @dshin-moz' proposal instead. That behavior is also easier for authors to comprehend IMO. Otherwise, we could actually consider removing proximity entirely (as @emilio is hinting at). I kind of regret not making |
That also seems good to me.
Proximity is actually the CSS feature we are most excited about. It is very common for us to have components and layouts with areas that can contain other components. With both potentially having content from a wysiwyg editor. Many CMS's are moving towards very flexible page builders where content editors can nest components in various ways. The only way to style these as designers would expect them to appear is by using An abstracted example of what we often encounter:
(I bet that component authors encounter similar issues but at a more granular/smaller level?) I really hope that we don't lose proximity. |
Yeah, I understand concerns about proximity being heuristic and associated with scope, but:
But I haven't actually seen any use-cases where you want one of these behaviors and don't want the other. I've only seen hand-wringing about it, and no examples of why it's not useful or should be separate. I'm happy to have that conversation here or elsewhere. I also don't want to ship something if we don't think it will work. But I'm not sure how to respond when the concerns are never fleshed out beyond vague unease. |
Background:
The published definition of 'scope proximity' states that:
However, in the Editor's Draft, the second paragraph was removed and the first paragraph adjusted, so that each scoped selector has one single scope root and a single proximity number.
In our publishing discussion last week, @mdubet asked to reconsider this.
How it might work:
In order to find a 'proximity', we need both a 'subject' element and a ':scope' element. Then we count the 'steps' between one and the other.
Nested
@scope
rules are allowed. Each scope rule's<scope-start>
selector is 'scoped' by the parent scope rule. If we want scopes to accumulate with nesting, we have to determine which subjects we are comparing to which roots. Given this example:I see two options (though I believe they might be functionally the same??). The scope proximity weight for
c
is one of:[c-to-b-distance, c-to-a-distance]
[c-to-b-distance, b-to-a-distance]
In either case, I believe the proposal is to compare proximities from inner-most to outer-most.
But why?
I think this would be a reasonable approach. At least, it makes some sense to me that things might work this way. But I can't think of an actual use-case where I would rely on this behavior. I'm not opposed, but I'm also not sure how useful or complex it is.
The text was updated successfully, but these errors were encountered: