0

我在下面有一个imports.html页面,我正在硫化。

奇怪的是……通常在我的index.html我有 <link rel="import" href="bower_components/polymer/polymer.html">……这不在imports.html。但是当我硫化时imports.html,不知何故它被包含在内,我必须<link rel="import" href="bower_components/polymer/polymer.html">从我的index.html. 否则,我会得到

Uncaught NotSupportedError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'dom-module'. A type with that name is already registered.

polymer.html当我硫化时来自哪里imports.html?因为它不在imports.html.


!-- custom style sheets-->
<link rel="stylesheet" href="css/splash.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/fade-title-animation.css">
<link rel="stylesheet" href="css/paper-ripple.css">
<link rel="stylesheet" href="css/slider-animation.css">
<link rel="stylesheet" href="bower_components/components-font-awesome/css/font
-awesome.min.css">
<!-- custom style sheets-->

<!-- bower components -->
<link rel="import" href="bower_components/paper-menu/paper-menu.html">
<link rel="import" href="bower_components/paper-item/paper-item.html">
<link rel="import" href="bower_components/paper-drawer-panel/paper-drawer-panel.html">
<link rel="import" href="bower_components/iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="bower_components/paper-header-panel/paper-header-panel.html">
<link rel="import" href="bower_components/iron-collapse/iron-collapse.html">
<link rel="import" href="bower_components/iron-icon/iron-icon.html">
<link rel="import" href="bower_components/iron-icons/editor-icons.html">
<link rel="import" href="bower_components/paper-ripple/paper-ripple.html">
<link rel="import" href="bower_components/iron-icons/iron-icons.html">
<link rel="import" href="bower_components/iron-icons/image-icons.html">
<link rel="import" href="bower_components/paper-toolbar/paper-toolbar.html">
<link rel="import" href="bower_components/paper-material/paper-material.html">
<link rel="import" href="bower_components/paper-card/paper-card.html">
<link rel="import" href="bower_components/iron-media-query/iron-media-query.html">
<link rel="import" href="bower_components/paper-fab/paper-fab.html">
<link rel="import" href="bower_components/paper-button/paper-button.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="bower_components/paper-tabs/paper-tabs.html">
<!-- bower components -->

<!-- custom elements -->
<link rel="import" href="elements/portfolio/cards/card-behavior.html">
<link rel="import" href="elements/page-behavior.html">
<link rel="import" href="elements/page-styles.html">
<link rel="import" href="elements/footer-custom.html">
<link rel="import" href="elements/toolbar-menus/paper-menu-custom.html">
<link rel="import" href="elements/toolbar-menus/paper-tabs-custom.html">
<link rel="import" href="elements/portfolio/cards/portfolio-card-styles.html">
<link rel="import" href="elements/portfolio/portfolio-display.html">
<link rel="import" href="elements/portfolio/portfolio-page.html">
<link rel="import" href="elements/portfolio/cards/cloud-share-image-card.html">
<link rel="import" href="elements/portfolio/cards/cloud-monitor-card.html">
<link rel="import" href="elements/portfolio/cards/legacy-darin-card.html">
<link rel="import" href="elements/portfolio/cards/dad-site-card.html">
<link rel="import" href="elements/portfolio/cards/gulp-newy-card.html">
<link rel="import" href="elements/portfolio/cards/darin-hensley-card.html">
<link rel="import" href="elements/portfolio/cards/krunch-uploader-card.html">
<link rel="import" href="elements/resume/resume-page.html">
<link rel="import" href="elements/resume/resume-display.html">
<link rel="import" href="elements/contact-display.html">
<!-- custom elements -->

<!-- js -->
<script src="js/misc.js" ></script>
<script src="bower_components/page/page.js"></script>
<script src="js/router.js"></script>
<script src="js/resume.js"></script>
<script src="js/pdf.js"></script>
<script src="js/pdf.worker.js"></script>
<script src="js/initialize.js" defer></script>
<!-- js -->
4

1 回答 1

4

您有一个导入 polymer.html 的元素遍历自定义元素并检查包含此导入的文件。(我认为所有聚合物元素都包含此导入) 硫化扫描递归扫描以进行导入。

真正的问题是您只硫化导入文件而不是所有索引。如果您只想硫化imports.html 文件,则必须将所有导入文件放入该文件中。

通常情况下会发生什么(在您硫化之前)

浏览器解析 html 文件。如果它有 2 个具有相同 url 的导入,则将其导入一次。

在您的情况下,硫化导入文件。

现在它包含了polymer.html,然后当您在索引中导入此文件时,浏览器不知道在硫化文件中您有polymer.html 文件。所以它再次导入它..

于 2016-02-15T01:25:13.307 回答