Creating Custom/nested element-registries

66 views
Skip to first unread message

alessandro meyer

unread,
Apr 1, 2015, 5:36:05 PM4/1/15
to polym...@googlegroups.com
Hello There

I've been trying to found out whether it is possible to create nested registries either through polymer or native web components. But the W3C Spec is not really explicit enough for me about it.


Says:
When creating a template contents owner document, use a new empty registry.

How would I do that? My goal is to have scoped imports so elements never clash in the global scope. If there are other approaches to it I'm happy to give them a try.

Thanks!
Alessandro

Daniel Freedman

unread,
Apr 1, 2015, 6:06:38 PM4/1/15
to alessandro meyer, polymer-dev
As far as I know, there is nothing in the spec as of yet to allow for user defined registries. I believe this is planned for a later iteration of the spec.

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/53c86322-eb32-4f23-84a3-0d2727d911bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

alessandro meyer

unread,
Apr 7, 2015, 7:41:39 AM4/7/15
to polym...@googlegroups.com, alessand...@gmail.com
Thank you for your answer.

Is there a JS-based temporal solution (hack) to this?

Dominic Cooney

unread,
Apr 8, 2015, 1:45:46 AM4/8/15
to alessandro meyer, polymer-dev
This is kind of a hack, but you can create a new registry by creating an IFRAME and registering elements through its document, for example:

<iframe id="registry2" src="javascript:"></iframe>

var iframe = document.querySelector('#registry2');
iframe.contentDocument.registerElement(...);

etc.

There are other ways, but they all depend on this one weird trick of creating a second, unrelated document and using its registry. Having the iframe is convenient (although heavier) because you can also run scripts in there, and the scripts get an isolated global object.

HTH,

Dominic

Rob Dodson

unread,
Apr 9, 2015, 3:43:59 PM4/9/15
to Dominic Cooney, alessandro meyer, polymer-dev
that's an interesting trick, thanks for sharing it Dominic :)

Reply all
Reply to author
Forward
0 new messages