问题
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