Styling descendent element in slotted element

谁说我不能喝 提交于 2019-12-11 03:45:55

问题


Is it possible to select descendent element in slotted element?

Example like this:

::slotted(div p) {
        color: blue;
    }

<div><p>test</p><div>

It doesn't work


回答1:


No, you can only select top-level nodes with ::slotted().

The selector inside ::slotted() can only be a compound selector, so div p is not a valid one.

According to Hayato Ito :

The reason of this restriction is to make a selector style-engine friendly, in terms of performance.

See the styling example in the Shadow Dom v1 presentation.



来源:https://stackoverflow.com/questions/48389483/styling-descendent-element-in-slotted-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!