哪些步骤将重现该问题:
(1)在chrome浏览器中运行以下代码
(2)尝试在“With Shadow dom”和“Without Shadow dom”两个部分中双击“Second”一词。
预期结果:应该选择“第二”这个词(因为它在第-2节中工作)
实际行为:双击不选择文本。
var arr = document.querySelectorAll('#some-run');
var spans = Array.from(arr);
spans.forEach(function(span) {
var shadow = span.createShadowRoot();
var template = document.querySelector('#style-template');
shadow.innerHTML = template.innerHTML;
});
<p>Try to Double click on "Second" in the With and without shadow-dom sections below and observe the behaviour</p>
<p contentEditable="true" style={display: block;}>
<b>With Shadow dom</b><br/>
<span id="some-run">First</span>
<span id="some-run">Second</span>
<span id="some-run">Third</span>
</p>
<p contentEditable="true" style={display: block;}>
<b>Without Shadow dom</b><br/>
<span id="some-run-2">First</span>
<span id="some-run-2">Second</span>
<span id="some-run-2">Third</span>
</p>
<template id="style-template">
<style>
:host {
opacity: 1; /* A dummy style, can be replaced with anything else*/
}
</style>
<content></content>
</template>