PolymerElements / iron-form

Custom form element
https://www.webcomponents.org/element/PolymerElements/iron-form
63 stars 81 forks source link

Error during initialization when children contain a comment node #274

Open tedplumtree opened 6 years ago

tedplumtree commented 6 years ago

Description

I have a use case where I want my element's light DOM to be the children of the iron-form, i.e., the template looks like:

<iron-form>
  <form>
    <slot></slot>
  </form>
</iron-form>

Expected outcome

iron-form's #initializeValues succeeds normally in all cases

Actual outcome

When the light DOM contains an XML comment, i.e, if the node is a comment node, calling the legacy DOM API Polymer.dom blows up. I think it's the same issue as this one

I get an error saying that this.node[method] is undefined

in Polymer DOM's following line:

function forwardMethods(proto, methods) { ....

proto[method] = /** @this {DomApi} */ function() {
  return this.node[method].apply(this.node, arguments);
}
.....

Seems like to be the fix is as easy as checking that the method exists before calling it, or checking that this.node.tagName !== '#comment'. I know that the DOM API is deprecated, but could someone fix this low-hanging fruit?

Live Demo

Will provide if needed

Steps to reproduce

Will provide if needed

Browsers Affected

DoktorDaveJoos commented 5 years ago

same