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
While using CSS variables, I noticed that the current implementation only reflects the CSS rules that are defined in the domHost of a custom element. However, any ancestor could define a selector that matches a given node. Let me provide some examples to illustrate the issue:
Case 1:
<x-tree><style>
:host {
--foo: 1;
}
</style>
--foo is 1 as expected
<x-leave><style>
:host {
--foo: 2;
}
--foo is 2 as expected
</style></x-leave></x-tree>
Case 2:
<x-tree><style>
:host {
--foo: 1;
}
</style>
`--foo` is 1 as expected
<x-leave>
`--foo` is 1 as expected since it's inherited from the DOM host
</x-leave></x-tree>
I have concluded after a further investigation that the problem isn't the order of
as I suggested in #1459, but rather the the selector matching mechanism. For example, if we were using divs and css properties, we will get this result:
<style>
.tree {
color: red;
}
.substree {
color: blue;
}
.tree .subtree {
color: green;
}
</style><divclass="tree"><!-- color is red --><divclass="subtree"><!-- color is green since the selector `.tree .subtree` has higher precedence than `.subtree`--></div></div>
This is what the implementation of custom variables doesn't handle yet because it assumes that the only way you can override properties is by defining them in their immediate host. I think the rules that contain CSS variables should be propagated down the tree in order to make it work.
So for example:
<head><styleis="x-style">
x-tree {
--foo: 2;
}
x-tree x-leave {
--foo: 3;
}
</style></head><x-tree><style>
:host {
--foo: 1;
}
</style>
--foo should be 2, so that it will work in the same way as regular CSS properties.
<x-leave>
--foo should be 3, instead of 1.
</x-leave></x-tree>
I hope it helps.
The text was updated successfully, but these errors were encountered:
This is by design. Polymer's custom property support is intended primarily to support cross scope styling, not inheritance from parent to child.
This is done for efficiency. We shim property values only at scope boundaries, not across the entire tree. To do so would require computing style inheritance through the entire dom tree, which we think is simply not practical.
Native custom properties will support these type of use cases.
These custom properties can be defined similar to other standard CSS properties
and will inherit from the point of definition down the composed DOM tree,
similar to the effect of color and font-family.
While using CSS variables, I noticed that the current implementation only reflects the CSS rules that are defined in the
domHost
of a custom element. However, any ancestor could define a selector that matches a given node. Let me provide some examples to illustrate the issue:Case 1:
Case 2:
I have concluded after a further investigation that the problem isn't the order of
as I suggested in #1459, but rather the the selector matching mechanism. For example, if we were using divs and css properties, we will get this result:
This is what the implementation of custom variables doesn't handle yet because it assumes that the only way you can override properties is by defining them in their immediate
host
. I think the rules that contain CSS variables should be propagated down the tree in order to make it work.So for example:
I hope it helps.
The text was updated successfully, but these errors were encountered: