Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 421
Nevir Avatar asked Jun 05 '14 21:06

Nevir


1 Answers

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

like image 60
ebidel Avatar answered Oct 27 '22 00:10

ebidel