Firefox中的多个聚合物Web组件失败

soc*_*157 5 javascript firefox web-component polymer

我已经使用多个自定义组件在Chrome中成功构建了一个网站,一切都按预期工作.

如果我在演示页面上一次运行一个组件,它将在Firefox上呈现.现在,在使用多个自定义组件进行跨浏览器测试时,使用Firefox v41时它们都无法呈现*.(虽然一次快速刷新得到一些组件出现;侥幸?)

*我的意思是渲染失败是页面上dom show中的内容,但似乎没有投影到阴影dom中,也没有继承自定义组件中定义的样式或函数,只是继承了样式来自索引文件.

如何在Firefox的一个页面上显示多个dom-modules?

错误日志:

Error: DuplicateDefinitionError: a type with name 'dom-module' is already registered
TypeError: Polymer.Base._getExtendedPrototype is not a function
TypeError: Polymer.CaseMap is undefined
TypeError: this._desugarBehaviors is not a function
TypeError: this._meta.byKey is not a function
TypeError: Polymer.Base._hostStack is undefined
Run Code Online (Sandbox Code Playgroud)

索引文件:

<html>
<head>
    <link href='/css/styles.css' rel='stylesheet' type='text/css'>
    <script src="/bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
    <link rel="import" href="/bower_components/polymer/polymer.html">
    <link rel="import" href="/bower_components/ac-theme/color.html">
    <link rel="import" href="/bower_components/ac-theme/sizing.html">
    <link rel="import" href="/bower_components/ac-messagebar/ac-messagebar.html">
    <link rel="import" href="/bower_components/ac-site-footer/ac-site-footer.html">
</head>
<body>

<ac-messagebar>Message bar.</ac-messagebar>

    <ac-site-footer small-query="(max-width: 500px)">
        <section>
            <ul>
                <li>
                    Links<br/>
                    <ul>
                        <li><a href="#">Link 1</a></li>
                        <li><a href="#">Link 2</a></li>
                    </ul>
                </li>
            </ul>
        </section>
    </ac-site-footer>
</body>
Run Code Online (Sandbox Code Playgroud)

自定义组件结构:

<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../ac-theme/color.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../iron-flex-layout/classes/iron-flex-layout.html">
<link rel="import" href="../iron-media-query/iron-media-query.html">

<dom-module id="ac-site-footer">
<template>
    <style is="custom-style">
        :host {
            /*css;*/
        }
</style>
    <iron-media-query
            id="mq"
            query="{{smallQuery}}"
            query-matches="{{smallScreen}}"
            on-query-matches-changed="_screenChanged"
            ></iron-media-query>
    <div class="content-container">
        <content></content>
    </div>        
</template>
<script>
    Polymer({
        is: "ac-site-footer",
        properties: {
            smallQuery: {
                type: String,
                value: '(max-width: 600px)',
                notify: true
            }
        },
        ...
</script>
Run Code Online (Sandbox Code Playgroud)

Sri*_*rik 1

  1. 将所有 link rel="import"...从index.html 移动到一个名为elements.html(包括polymer.html)的文件。然后仅将elements.html 导入到index.html 文件中。

  2. 如果上述方法不起作用,请从 elements.html 文件中删除 import Polymer.html,并确保所有文件都*/ac-*/*.html具有 Polymer.html 的导入语句。