多个 Polymer Web 组件在 Firefox 中失败
Multiple Polymer Web Components Fail in Firefox
我已经使用多个自定义组件在 Chrome 中成功构建了一个站点,并且一切正常。
如果我在演示页面上一次 运行 一个组件,它会在 Firefox 上呈现。现在在使用多个自定义组件进行跨浏览器测试时,使用 Firefox v41 时它们都无法呈现*。 (虽然1次快速刷新有一些组件出现;侥幸?)
*我说的渲染失败是指dom中的内容显示在页面上,但没有投射到阴影中dom,也没有继承样式或者自定义组件中定义的功能,但仅继承索引文件中的样式。
如何让多个 dom 模块呈现在 Firefox 的一个页面上?
错误日志:
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
索引文件:
<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>
自定义组件结构:
<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>
将所有 link rel="import"...
从 index.html 移动到名为 elements.html 的文件(包括 polymer.html)。然后仅导入 elements.html进入你的 index.html 文件。
如果上述方法不起作用,请从您的 elements.html 文件中删除导入 polymer.html 并确保所有 */ac-*/*.html
文件都包含 [=24] 的导入语句=].
我已经使用多个自定义组件在 Chrome 中成功构建了一个站点,并且一切正常。
如果我在演示页面上一次 运行 一个组件,它会在 Firefox 上呈现。现在在使用多个自定义组件进行跨浏览器测试时,使用 Firefox v41 时它们都无法呈现*。 (虽然1次快速刷新有一些组件出现;侥幸?)
*我说的渲染失败是指dom中的内容显示在页面上,但没有投射到阴影中dom,也没有继承样式或者自定义组件中定义的功能,但仅继承索引文件中的样式。
如何让多个 dom 模块呈现在 Firefox 的一个页面上?
错误日志:
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
索引文件:
<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>
自定义组件结构:
<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>
将所有
link rel="import"...
从 index.html 移动到名为 elements.html 的文件(包括 polymer.html)。然后仅导入 elements.html进入你的 index.html 文件。如果上述方法不起作用,请从您的 elements.html 文件中删除导入 polymer.html 并确保所有
*/ac-*/*.html
文件都包含 [=24] 的导入语句=].