try this instead: document.body.appendChild(document.importNode(t.content, true));
does that work for you? On Tue, Jul 8, 2014 at 8:37 AM, Jelte Liebrand <[email protected]> wrote: > I'm slightly puzzled, and no doubt I'm doing something silly here, but I > have created my own element "my-element" which has an additional function > "foo()". When I place one of these guys declaratively on my page, it works > fine, eg: > > <my-element></my-element> > > This element is an instance of MyElement and it has the function foo(). > > However, if I place it (declaratively) inside a template, which I then > later clone in to my document, then the element does not appear to be > upgraded and does not have my foo() function. eg: > > in html: > <template id="t"> > <my-element></my-element> > </template> > > in javascript: > var t = document.getElementById('t'); > document.body.appendChild(t.content.cloneNode(true)); > > The element does end up in my DOM, but it just doesn't have the foo() > function nor is it an actual instanceof MyElement. > > Am I missing something obvious here? > > /Cheers, > Jelte > > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/polymer-dev/31060fba-4113-4b06-ad80-32e5232716b8%40googlegroups.com > <https://groups.google.com/d/msgid/polymer-dev/31060fba-4113-4b06-ad80-32e5232716b8%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/CAJj5OwDbb3CcRFmc-smnNMnWNh4_zL8RhZByHzp03gNW%3DDbJpQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
