Windows上的Polymer Web组件和Mozilla Firefox使用Webjars

时间:2017-05-05 10:04:36

标签: firefox compatibility polymer-1.0 webjars

我正在尝试为Firefox启用Polymer Web组件,以便我可以浏览Firefox上的Polymer网页。

我尝试了这些说明,但没有任何改变,似乎Firefox完全忽略了我的组件。

https://www.designedbyaturtle.co.uk/2015/how-to-enable-web-components-in-firefox-shadow-dom/

我也在我的webcomponents.js中导入index.html polyfill。

所以,我所做的是以下内容:

我在目录test-firefox.html中编写了以下Web组件elements

<dom-module name="test-firefox">
  <template>
    <h2>Firefox says hi too!</h2>
  </template>
  <script>
    Polymer({
      is: 'test-firefox'
    });
  </script>
</dom-module>

这是我的index.html文件:

<!doctype html>
<html>
  <head>
      <link rel="import" href="webjars/polymer/1.6.1/polymer.html">
      <script src="webjars/webcomponentsjs/0.7.22/webcomponents.js"></script>
      <script src="webjars/webcomponentsjs/0.7.22/webcomponents-lite.min.js"></script>

      <link rel="import" href="elements/test-firefox.html">

  </head>
  <body>
    <h1>Hello Firefox!</h1>
    <test-firefox></test-firefox>
  </body>
</html>`

正如您所看到的,我使用的是相应的bower_componentswebjarsPolymerwebcomponents.js)而不是webcomponents-lite.min.js。我已经为pom.xml中的那些添加了依赖项,它们通常已安装。

所以我注意到这种情况很奇怪:

  • 对于谷歌浏览器,一切都很好。
  • 对于Linux上的Mozilla Firefox,同样。
  • 对于Win10上的Mozilla Firefox,Web组件没有渲染,就像浏览器完全忽略它一样。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

你可以改写你的问题吗?

您无需启用任何内容即可让网站在Firefox中运行(当然您可以访问https://www.polymer-project.org/并且它适用于您)。

如果firefox“忽略”你的组件,那么你可能缺少这些元素的导入。

查看此页面https://www.polymer-project.org/1.0/docs/devguide/registering-elements,了解如何使用<link rel="import" href="bower_components/polymer/polymer.html">。您还需要以这种方式导入自己的组件才能使用它们。