【发布时间】:2014-08-09 10:25:05
【问题描述】:
为什么下面的代码中没有显示“footer text1”?
我的浏览器是 Chrome 36.0.1985.125
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="example">
<h2>Eric</h2>
<h2>Bidelman</h2>
<div>Digital Jedi</div>
<h4>footer text1</h4>
<h4>footer text2</h4>
</div>
<template id="sdom">
<header>
<content select="h2"></content>
</header>
<section>
<content select="div"></content>
</section>
<footer>
<content select="h4:first-of-type"></content>
</footer>
</template>
<script type="text/javascript">
var container = document.querySelector('#example');
var root = container.createShadowRoot();
var t = document.querySelector('#sdom');
var clone = document.importNode(t.content, true);
root.appendChild(clone);
</script>
</body>
</html>
【问题讨论】:
-
应该的。规范说它接受任何复合选择器,
h4:first-of-type肯定是一个有效的复合选择器。 -
哦...顺便说一句,我的浏览器是 Chrome 36.0.1985.125。
-
似乎没有一个伪类起作用(尝试过:first、first-child、first-of-type、last、last-child、nth-child)。
-
谢谢。我在code.google.com/p/chromium/issues/… 报告了这个
标签: html css-selectors web-component shadow-dom