How can I use the :first-child selector w/ shadow DOM's <content> element?

放肆的年华 提交于 2019-12-10 14:53:00

问题


I'd like to extract the first paragraph from a custom element's content (as a summary). I would expect the following to work:

<polymer-element name="x-thing" noscript>
  <template>
    <segment class="summary">
      <content select="p:first-child"></content>
    </segment>
    <segment>
      <content></content>
    </segment>
  </template>
</polymer-element>

Unfortunately, the <content select="p:first-child"> doesn't appear to match anything :(

Here's a corresponding codepen.


回答1:


Only :not() is supported in the Shadow DOM spec: http://w3c.github.io/webcomponents/spec/shadow/#dfn-matching-criteria

Relevant bug: http://crbug.com/343332



来源:https://stackoverflow.com/questions/24070848/how-can-i-use-the-first-child-selector-w-shadow-doms-content-element

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