如何:从外部阴影主机将元素插入阴影DOM?

时间:2016-02-21 14:47:01

标签: javascript html web

据我研究过,只能将元素插入阴影主机内的阴影dom。

示例:

<div id="myShadowHost"><h1>This is my host</h1></div>


<script>
//attach a shadow to myShadowHost
var myHost=document.querySelector('#myShadowHost').createShadowRoot();
//Declare an insertion point 
var content = document.createElement('content');
//select element to pull into the insertion point, in this case the h1
content.setAttribute('select', 'h1');
//append to shadowHost the insertion point and pulled element.
myHost.appendChild(content);
</script>`

最终,我想进入阴影主机之外的阴影元素。

0 个答案:

没有答案