using shadow dom in Internet Explorer

天涯浪子 提交于 2019-12-11 03:26:32

问题


The below code works in chrome but not in Internet Explorer. Is there any way to use it in Internet Explorer?

    <html>
      <head></head>
     <body>
  <div>
    <h4>My Content Heading</h4>
    <p>My content text</p>
  </div>

  <script>
   var myContent = document.querySelector('div');  
   var shadowroot = myContent.createShadowRoot(); 
   shadowroot.innerHTML =
   '<h2>Inserted Heading</h2> <content select="p"></content>';
  </script>
  </body>
</html>

回答1:


Internet explorer (and new Edge browser) doesn't support shadow DOM natively. You can use polyfill to achieve desired behaviour.



来源:https://stackoverflow.com/questions/31720737/using-shadow-dom-in-internet-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!