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 h-select-item (package:polymer/src/instance.dart:170) #21439

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

Comments

@DartBot
Copy link

DartBot commented Oct 28, 2014

This issue was originally filed by dart.dev.c...@gmail.com


Had problems with previous submission - this is the intended submission. Cannot find how to delete previous submission. Apologies.

What steps will reproduce the problem?

  1. Create a dart project eg polymer_proto_type_bug.
  2. Copy the folders/files of the attached zip (unzip first) and copy them to the prjoect created in 1. Make certin the .yaml files is as present in the zip and contains - html_components: 0.3.0 - as this is the library that the problem relates.
  3. Upgrade the project and run from Dartium. Observe that a single paper-input is displayed with the Labelling "label". There are no problems here.
  4. Examine the entry_point polymer_prototype_bug.html file. Note the commented line below:
        <!--<link href = '../lib/component/unit_form.html' rel = 'import'> -->
  5. Uncomment the above line and run the application in Dartium.
  6. The application does not run and the console outputs the following:
       Exception: Already registered (Polymer) prototype for element h-select-item (package:polymer/src/instance.dart:170)

What is the expected output? The paper-input as shown plus an html_component of select_checkbox_menu.html containing checkboxes corresponding to the values in the map -

  @­observable
  Map<String, String> unitSelectItems =
    {
      'mm': 'mm',
      'cm': 'cm',
      'm': 'm',
      'litre': 'liter',
      'inches': 'inches',
      'foot': 'foot',
      'feet': 'feet',
      'pint': 'pint',
      'quart': 'quart',
      'cup': 'cup',
      'minute': 'minute',
      'hour': 'hour',
      'day': 'day',
      'month': 'month',
      'year': 'year'
    };

found in the unit_form.dart.

An example of how the custom-element should appear can be found at http://szgabsz91.github.io/html-components/#/input/select-checkbox-menu. Click on the drop-down arrow of the 'Movies' below the line Select Checkbox Menu.

Please include the following information:

  • Dart SDK version: 1.72 and 1.8.0
  • polymer package version: 0.15.1+1 and above
  • Operating system: Windows 8.1 x64
  • Browser (if any): Run in Dartium during development only
  • Eclipse Dart plugin Dart Editor 1.72
  • Eclipse Luna Service Release 1 (4.4.1)
    Attachment:
    polymer_prototype_bug.zip (13.43 KB)
@jakemac53
Copy link
Contributor

Issue #21438 has been merged into this issue.

@sigmundch
Copy link
Member

Hi, I haven't tried the example directly, but it sounds like the problem here is the path you have to import a shared component. HTML imports are picky and will only recognize that two imports are loading the same file if the imports resolve to the same URL.

Because HTML imports know nothing about Dart, they don't know that a url to "../lib" or a URL to "packages/package_name/" are the same. So you can easily run into a problem with imports that use the form "../lib". That's why we encourage that you use "packages/" urls instead. This is similar to how in Dart we use "package:foo/x.dart" and not "../lib/x.dart", so that everyone uses the same URL to reach the library.

You can find more details on what we do/recommend in this article: https://www.dartlang.org/polymer/app-directories.html

 
In your example, replace both urls, instead of using "../lib":

<link href = '../lib/component/...' rel = 'import'>

use "packages/polymer_prototype_bug" (the name of your package):

<link href = 'packages/polymer_prototype_bug/component/...' rel = 'import'>

Cheers!


Added AsDesigned label.

@DartBot
Copy link
Author

DartBot commented Oct 28, 2014

This comment was originally written by dart.dev.c...@gmail.com


Hi sigmund,
Thanks for the reply.

    <link href = 'packages/polymer_prototype_bug/component/description_form.html' rel = 'import'>
    <link href = 'packages/polymer_prototype_bug/component/unit_form.html' rel = 'import'>

I made the changes you suggested but the result is the same - Exception: Already registered (Polymer) prototype for element h-select-item (package:polymer/src/instance.dart:170)

@sigmundch
Copy link
Member

Hey dart.dev.clarke - I was finally able to try your example, and I can see that the problem is triggered from the html_components package.

It seems that 'package:html_components/input/select_checkbox_menu.dart' has an export of 'package:html_components/input/select_item.dart', which makes us incorrectly register h-select-item twice (the first time when when we discover it from select_item.html, and the second time when we see that export).

Technically it is not incorrect to have that export, so we need to add some more logic to the polymer transformers to handle this special case. If you are the owner of that package, though, and would like to continue making progress without waiting for a fix, then changing the code to remove the export will fix the issue (I just tried that locally and it seemed to work).


Removed Pkg-Polymer label.
Added Pkg-PolymerBuild, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Oct 28, 2014

This comment was originally written by dart.dev.c...@gmail.com


Thanks Sigmund.
I appreciate the help. Yes, I did see the import/export but did not know if it was significant. I am not the author of html_component but I am in contact with the same about this issue. I agree that the polymer transformer logic is necessary to handle the spacial case since the html_component package is 'technically' correct.

About when will a fix be available from the polymer side?

Cheers

@sigmundch
Copy link
Member

Honestly I was hoping I could look this week but I haven't had a chance to do so yet. I'll keep you posted.

Meanwhile there are two hacky tricks you can do to work around the problem:

 - you can download the html_component package, modify it locally and depend on your local copy using a path dependency or dependency_override.

 - you can add a transformer that runs after polymer and remove one line from the generated code. If you run pub build --mode=debug, you will be able to see the output bootstrap.dart file and read what we generate. The generated code will have two lines that register select-item, so your transformer would have to remove one of them.

Cheers

@DartBot
Copy link
Author

DartBot commented Nov 2, 2014

This comment was originally written by dart.dev.clark...@gmail.com


Hello Sigmund,
I hope you will be able to correct the bug this week. I tried what you said but it did not work for me. Could you please zip and send your hack for me to dart.dev.clarke @­ gmail dot com address. At least this will allow me to continue working in the meantime.

Cheers

@sigmundch
Copy link
Member

I just sent a CL out for review: https://codereview.chromium.org/700733002/


Added Started label.

@jakemac53
Copy link
Contributor

fix submitted, I am assuming this is fixed now


Set owner to @sigmundch.
Added Fixed label.

@sigmundch
Copy link
Member

Yes :) - The fixed package is now available in version 0.15.1+4 from pub.

@DartBot
Copy link
Author

DartBot commented Nov 20, 2014

This comment was originally written by dart.dev.clark...@gmail.com


The fixed package is now available in version 0.15.1+4 from pub.
However, it seems that the problem has resurfaced in polymer 0.15.1+5. Could check it out please.

Thanks

@sigmundch
Copy link
Member

The fix is also there in 0.15.1+5. I verified your example above, and seems to be working here with 0.15.1+5.

I noticed that pub-serve may be caching results of building code in the .pub folder under your project root. It worked for me after I deleted the .pub/ folder under the root of the package. Maybe that's the issue you are seeing?

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

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

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