Exception: Already registered (Polymer) prototype for element x #323
Comments
<img src="https://avatars.githubusercontent.com/u/4865287?v=3" align="left" width="48" height="48"hspace="10"> Comment by lrhn Added Pkg-Polymer, Triaged labels. |
<img src="https://avatars.githubusercontent.com/u/4865287?v=3" align="left" width="48" height="48"hspace="10"> Comment by lrhn Added Area-Pkg label. |
<img src="https://avatars.githubusercontent.com/u/984921?v=3" align="left" width="48" height="48"hspace="10"> Comment by jakemac53 Set owner to @jakemac53. |
<img src="https://avatars.githubusercontent.com/u/984921?v=3" align="left" width="48" height="48"hspace="10"> Comment by jakemac53 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. |
<img src="https://avatars.githubusercontent.com/u/984921?v=3" align="left" width="48" height="48"hspace="10"> Comment by jakemac53 Fixed in dart-lang/sdk@25fc2f9, 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. |
<img src="https://avatars.githubusercontent.com/u/984921?v=3" align="left" width="48" height="48"hspace="10"> Comment by jakemac53 Added Fixed label. |
<img src="https://avatars.githubusercontent.com/u/984921?v=3" align="left" width="48" height="48"hspace="10"> Comment by jakemac53 published as 0.15.0+2 |
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?" |
<img src="https://avatars.githubusercontent.com/u/613647?v=3" align="left" width="48" height="48"hspace="10"> Comment 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> 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. |
Originally opened as dart-lang/sdk#21332
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();
}
The text was updated successfully, but these errors were encountered: