You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's been a while since the discussion of allowing more complex ::slotted() styling. Being able to style only the slotted elements in a specific slot is still missing.
Goal: To apply complex styling rules to slotted elements using their rendered order.
This kind of nested styling with ::slotted() is needed to properly style items based on their rendered order in their specific slots. Attempting to use basic global CSS rules become fragile when a component has multiple slots as pseudo-classes referencing positions are evaluating on all the children not just the specific slot elements.
However, the performance issues appear to be related to finding rules. This leads to many situations where one can simply write a global CSS rule that does an almost identical behavior. The major difference being it runs the selector on the light dom and not the rendered slotted elements, so the list of elements is different as mentioned before. The fix would then be to modify the global rule to only style the slotted elements.
Example 1
A simple example is slot:not([name])::slotted(ul:first-child > li) {}
When the style is first processed like a regular global CSS rule it would be valid for both li tags. The metadata :slot() would reevaluate the rule in the context of the rendered position in the slot. In theory this transformed rule basically tags the elements affected by the rule to run the rule in the slot rendered context.
I'm not familiar with implementations, but would such an idea work and bypass any performance issue?
Example 2
If that idea does work, I have a more specific example of how I want to use this. This uses some syntax I described in #1037 to handle inheritance. The goal in this example is to apply custom styling to children nodes that have previous and next siblings. (Note: I'm introducing syntactic sugar - sibling selector which would just transform to the :has() pseudo-class):
The rule runs as normal matching the ui-treenode elements that have ui-treenode's before and after respectively. But
Conclusion
I have further thoughts about ::part() as well if this is possible.
Also as a lot of these issues are very old (with discussions going back before 2018) so I don't know who to tag that would be familiar with the implementation feasibility.
The text was updated successfully, but these errors were encountered:
It's been a while since the discussion of allowing more complex
::slotted()
styling. Being able to style only the slotted elements in a specific slot is still missing.Goal: To apply complex styling rules to slotted elements using their rendered order.
This kind of nested styling with
::slotted()
is needed to properly style items based on their rendered order in their specific slots. Attempting to use basic global CSS rules become fragile when a component has multiple slots as pseudo-classes referencing positions are evaluating on all the children not just the specific slot elements.Previous discussions on allowing complex rules for
::slotted()
have mentioned performance issues. https://stackoverflow.com/a/61631668/254381 ( #889 (comment) )However, the performance issues appear to be related to finding rules. This leads to many situations where one can simply write a global CSS rule that does an almost identical behavior. The major difference being it runs the selector on the light dom and not the rendered slotted elements, so the list of elements is different as mentioned before. The fix would then be to modify the global rule to only style the slotted elements.
Example 1
A simple example is
slot:not([name])::slotted(ul:first-child > li) {}
When
li
is looking for rules it would need to search up the tree for all slots and then their rules. Rewriting the rule in the global CSS as:But it needs to know the
ul
must be in the default slot so extra metadata is added to the rule:When the style is first processed like a regular global CSS rule it would be valid for both
li
tags. The metadata:slot()
would reevaluate the rule in the context of the rendered position in the slot. In theory this transformed rule basically tags the elements affected by the rule to run the rule in the slot rendered context.I'm not familiar with implementations, but would such an idea work and bypass any performance issue?
Example 2
If that idea does work, I have a more specific example of how I want to use this. This uses some syntax I described in #1037 to handle inheritance. The goal in this example is to apply custom styling to children nodes that have previous and next siblings. (Note: I'm introducing syntactic sugar
-
sibling selector which would just transform to the :has() pseudo-class):Rough example with a global CSS rule: https://jsfiddle.net/sirisian/kjzt2qdb/15/
The two CSS lines used to style relative to siblings:
Would be converted to the global rules:
The rule runs as normal matching the
ui-treenode
elements that haveui-treenode
's before and after respectively. ButConclusion
I have further thoughts about
::part()
as well if this is possible.Also as a lot of these issues are very old (with discussions going back before 2018) so I don't know who to tag that would be familiar with the implementation feasibility.
The text was updated successfully, but these errors were encountered: