Search code examples
dartcustom-element

Extending TemplateElement


I am not using Polymer and I am trying to extend the TemplateElement

class ItemTemplate extends TemplateElement{
  ItemTemplate.created():super.created();
}

and then register it

document.registerElement('item-template', ItemTemplate,extendsTag:'template');

but when i add the following to my html test page

  <template>
    template
  </template>

  <item-template>
    item-template
  </item-template>

in Chromium it outputs

item-template

which means the new element that extends TemplateElement is active and not acting as a template, any idea why?

E:this is not a duplicate i said i am not using polymer and there is no polymer in the tags and its specifically about the behavior of the html5 TemplateElement


Solution

  • I have no experience with extending elements without Polymer but I'm pretty sure you still need the `is="xx-yy" attribute like

    <template is="item-template">
      item-template
    </template is="item-template">
    

    when you're extending a DOM element.

    Maybe there are other measurements necessary to make it work but this should at least bring you a step closer (maybe an error message about what's still missing)