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

Exception: Already registered (Polymer) prototype for element x #21332

Closed
DartBot opened this issue Oct 15, 2014 · 10 comments
Closed

Exception: Already registered (Polymer) prototype for element x #21332

DartBot opened this issue Oct 15, 2014 · 10 comments
Assignees
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams.

Comments

@DartBot
Copy link

DartBot commented Oct 15, 2014

This issue was originally filed by def...@gmail.com


I've two polymer elements that share the same dart file. In the dart file I declare both the PolymerElement classes.

Until polymer 0.15.0+1 it was working fine. I've updated the project to polymer 0.15.1 and now I get this exception:

    Exception: Already registered (Polymer) prototype for element my-polymer-a

Where my-polymer-a is the first declared polymer.

I think the polymer transformer is trying to register it two times, the first scanning the my-polymer-a html file, the second when scanning the my-polymer-b html file.

This issues breaks our current use of polymer elements and we're forced to refactor a large codebase towards many finer-grained libs we don't really need and will find difficult to move about as we refactor.

Here the code:

mypolymerA.html
<link rel="import" href="packages/polymer/polymer.html">

<polymer-element name="my-polymer-a">
    <template>
      <div>Hello I'm A</div>
    </template>
  <script type="application/dart" src="mypolymers.dart"></script>
</polymer-element>

mypolymerB.html
<link rel="import" href="packages/polymer/polymer.html">

<polymer-element name="my-polymer-b">
    <template>
      <div>Hello I'm B</div>
    </template>
  <script type="application/dart" src="mypolymers.dart"></script>
</polymer-element>

mypolymers.dart
import 'package:polymer/polymer.dart';

@CustomTag('my-polymer-a')
class MyPolymerA extends PolymerElement {
  
  MyPolymerA.created() : super.created();
  
}

@CustomTag('my-polymer-b')
class MyPolymerB extends PolymerElement {
  
  MyPolymerB.created() : super.created();
  
}

@lrhn
Copy link
Member

lrhn commented Oct 17, 2014

Added Pkg-Polymer, Triaged labels.

@lrhn
Copy link
Member

lrhn commented Oct 17, 2014

Added Area-Pkg label.

@jakemac53
Copy link
Contributor

Set owner to @jakemac53.
Added Started label.

@jakemac53
Copy link
Contributor

Looks like an issue with out inliners, if the same dart file is seen more than once then the extras should just be ignored but we are inlining it each time. This isn't actually a new bug, it was just being hidden previously since there was a bug in the check for duplicate registrations googlearchive/polymer-dev@71d2041.

@jakemac53
Copy link
Contributor

Fixed in r41245, but this will still throw a warning. The real solution for you here should be to put your script file in its own html file, and import that instead of your script.

@jakemac53
Copy link
Contributor

Added Fixed label.

@jakemac53
Copy link
Contributor

published as 0.15.0+2

@DartBot
Copy link
Author

DartBot commented Oct 24, 2014

This comment was originally written by defaveri...@gmail.com


With "The real solution for you here should be to put your script file in its own html file, and import that instead of your script." do you mean "put your script file in its own DART file, and import that instead of the entire library?"

@DartBot
Copy link
Author

DartBot commented Oct 24, 2014

This comment was originally written by @mareksuscak


Well if you use build logs in output that show warnings on the page then if you click "more" button you will find exact instructions how to workaround it.

In summary you have to create an HTML file (e.g. script_thats_used_multiple_times.html) with the following content:

<!DOCTYPE html>
<script type="application/dart" src="script_thats_used_multiple_times.dart"></script>

then of course delete the original <script> from all polymer components that used this file previously and put the import above the <polymer-element>

<link rel="import" href="script_thats_used_multiple_times.html">

which will import previously created HTML file. Simple.

@DartBot DartBot added Type-Defect area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. labels Oct 24, 2014
@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

This issue has been moved to dart-archive/polymer-dart#323.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams.
Projects
None yet
Development

No branches or pull requests

4 participants