Upcoming breaking change to Custom Elements--elements in templates won't come alive

87 views
Skip to first unread message

Dominic Cooney

unread,
Nov 20, 2013, 1:52:16 PM11/20/13
to polymer-dev
Hi Polymerase,

Starting with the next Chrome Canary, Custom Elements in templates aren't going to be "live." This means Custom Elements in templates are more like <script> and friends--inert.

This means if you're pulling content out of a template and you want the Custom Elements in the template to pick up the definitions registered with the main document, instead of

var goodies = myTemplate.content.cloneNode(true);
// do something with goodies

you should do

var goodies = document.importNode(myTemplate.content);
// do something with goodies

Technically, the template document has its own set of definitions, so you could set up Custom Element definitions there with myTemplate.content.ownerDocument.register(...). But you probably don't want to do that.

More context: W3 bug 23839.

I'm happy to take questions, feedback.

Dominic

Addy Osmani

unread,
Nov 21, 2013, 7:48:49 AM11/21/13
to polym...@googlegroups.com, domi...@chromium.org, Eric Bidelman
Eric, is it worth us doing a PSA on @polymer about the change away from live? A quick search shows a few community elements use the old form.

Eric Bidelman

unread,
Nov 21, 2013, 11:34:11 AM11/21/13
to Addy Osmani, polymer-dev, Dominic Cooney, Eric Bidelman
That would be great, along with the G+ page. Can you point it to this thread?


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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages