Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymer throws error in Canary when registering an element via import #290

Closed
robdodson opened this issue Sep 23, 2013 · 7 comments
Closed
Assignees

Comments

@robdodson
Copy link
Contributor

It looks like there's an issue with the way imports and polymer element registration works in Chrome Canary. I get an error in the console but things seem to work otherwise.

Seen on Chrome 31.0.1640.2 canary

<!-- index.html -->
<!DOCTYPE html>
<html>
  <head>
    <!-- 1. Load Polymer -->
    <script src="../lib/polymer.min.js"></script>
    <!-- 2. Load a component -->
    <link rel="import" href="./imports/x-foo.html">
  </head>
  <body>
    <!-- 3. Declare the component by its tag. -->
    <x-foo></x-foo>
  </body>
</html>
<!-- imports/x-foo.html -->
<polymer-element name="x-foo">
  <template>
    <span>I'm <b>x-foo</b> with a prototype.</span>
  </template>
  <script>
    Polymer('x-foo', {
      created: function() {
        console.log('x-foo all up in here!');
      }
    });
  </script>
</polymer-element>

Outputs:

x-foo all up in here! VM773 x-foo.html:8
Uncaught InvalidStateError: Failed to call 'register' on 'Document' for type 'x-foo': a type with that name is already registered. 
@morethanreal
Copy link
Contributor

I can only reproduce this with "Native HTMLImports" enabled. Native HTML Imports are not yet supported in Polymer as we're waiting for the API to stabilize, but we're working on it.

@robdodson
Copy link
Contributor Author

yeah I've got the imports flag turned on in canary. good to know!

@ghost ghost assigned sorvell and ebidel Sep 24, 2013
@addyosmani
Copy link
Member

@morethanreal is it possible to feature-detect native presence of HTML imports in order to work around the flag being turned on?

@dfreedm
Copy link
Member

dfreedm commented Sep 27, 2013

Native Imports can be feature detected, but I'm not sure they can be worked around. The imports will begin loading when the parser sees them, and scripts are supposed to run after imports.

Given that this flag is off by default, and the feature is being actively worked on in Canary, I think would be more prudent to just document this case and wait for the native implementation to be ready.

@ebidel
Copy link
Contributor

ebidel commented Sep 27, 2013

I'd vote for not even documenting it given native imports aren't ready yet.

On Fri, Sep 27, 2013 at 11:21 AM, Daniel Freedman
notifications@github.comwrote:

Native Imports can be feature detected, but I'm not sure they can be
worked around. The imports will begin loading when the parser sees them,
and scripts are supposed to run after imports.

Given that this flag is off by default, and the feature is being actively
worked on in Canary, I think would be more prudent to just document this
case and wait for the native implementation to be ready.


Reply to this email directly or view it on GitHubhttps://github.com//issues/290#issuecomment-25265944
.

@robdodson
Copy link
Contributor Author

FWIW, to work around this I just killed off the parser in boot.js

My fix

So far it hasn't blown anything up in my presentation and I can use polymer elements and vanilla custom elements in Canary.

@jyasskin
Copy link

jyasskin commented Nov 3, 2013

FWIW, a note in http://www.polymer-project.org/platform/html-imports.html would have saved me some time. I'd turned on "Experimental Web Platform features" as suggested at http://www.html5rocks.com/en/tutorials/webcomponents/customelements/#support, and it looked like HTML Imports would produce similarly-useful bug reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants