Element already registered (elements from a different server)

48 views
Skip to first unread message

fako...@gmail.com

unread,
Feb 23, 2015, 3:46:11 AM2/23/15
to polym...@googlegroups.com
ServerB defines an element like this:
  <link rel="import" href="../core-menu/core-menu.html">
  <polymer-element name=„elementB“….</polymer-element>

ServerA serves the index.html, which uses element B like this:
  <link rel="import" href="../core-menu/core-menu.html">
  <link rel="import" href="http://serverB.com/elementB.html">
  ...
  <elementB></elementB>
  ...

The issue is, that HTML import adds a hostname to the imports at ServerB. So core-menu.html will be imported twice with two different URLs. This results in an polymer „element already registered“ exception.

I think using elements from different URLs pr server is a usual use case, right.
So, what is the correct way to handle this?

We got around this by adding a polymer element server and write <link rel="import" href=„http://myPolymerServer/core-menu/core-menu.html“>. But thats not very convenient.

best Christopher

Eric Bidelman

unread,
Feb 23, 2015, 11:49:26 AM2/23/15
to fako...@gmail.com, polym...@googlegroups.com
The short answer is you can't use a CDN. CDNs are a hole in the HTML Imports story atm.

Imports need to resolve to the same URL to be de-duplicated correctly by the browser. Serving the same component from two different URLs won't be deduped properly. This is why we recommend bringing in components locally using Bower and serving them from your own setup.

IMO, this is one of the biggest issues Polymer and the standards process needs to solve. It prevents the most convenient reuse of components.

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/980b43a8-48d8-4760-97f5-100c0f8f230e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

fako...@gmail.com

unread,
Feb 24, 2015, 2:01:30 AM2/24/15
to polym...@googlegroups.com
Thanks for your Answer Eric.

But, we do not use a CDN.

What we tried in our specific project was to modularize our applications in a way that specific Polymer elements are delivered by dedicated servers (so they have a dedicated URL).
A kind of dashboard imports these elements to provide a common/combined UI.

Anyway, I see that there is no way to do this, except to use full URLs for import or do some kind of build step.

best Christopher
Reply all
Reply to author
Forward
0 new messages