PolymerElements / iron-form

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

nested iron-forms overwrite element._parentForm #155

Open chrishsu opened 7 years ago

chrishsu commented 7 years ago

Description

https://github.com/PolymerElements/iron-form/blob/master/iron-form.html#L349

Expected outcome

Either the first form which gets the iron-form-element-register event should be the parentForm or there should be an array of parentForm's.

Actual outcome

The last form which gets the iron-form-element-register event becomes the parent form.

Steps to reproduce

<form id="outer" is="iron-form">
  <form id="inner" is="iron-form">
    <paper-input id="input" name="input"></paper-input>
  </form>
</form>

input._parentForm === outer

Browsers Affected

Chrome for sure.

tjsavage commented 7 years ago

This appears to be how <form> works as well, so I think the current behavior might be the expected behavior. According to the spec nested forms shouldn't be supported at all really. @notwaldorf WDYT?

chrishsu commented 7 years ago

From https://www.w3.org/TR/html5/forms.html#association-of-controls-and-forms,

A form-associated element is, by default, associated with its nearest ancestor form element (as described below), but, if it is reassociateable, may have a form attribute specified to override this.

This would seem to imply that the inner form should be it's parent.