How do I enable Shady DOM in Polymer 2.0?

前端 未结 1 739
执笔经年
执笔经年 2021-01-02 18:15

Polymer 1.x uses Shady DOM by default, but that could be changed at initialization by setting the window.Polymer object before importing polymer.

相关标签:
1条回答
  • 2021-01-02 19:00

    The Shady DOM shim was factored out of Polymer in 2.0 and moved into the v1 Web Components polyfill.

    To enable Shady DOM (instead of the default Shadow DOM), define the following window.ShadyDOM object before importing the v1 webcomponents-lite.js:

    <script>window.ShadyDOM = { force: true };</script>
    <script src="webcomponentsjs/webcomponents-lite.js"></script>
    

    codepen

    UPDATE: A simpler setting is to specify [shadydom] on the <script> tag:

    <script src="webcomponentsjs/webcomponents-lite.js" shadydom></script>
    

    codepen

    0 讨论(0)
提交回复
热议问题