angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Paragraph tags around form breaks validation/form in IE9

Open totalknowledge opened this issue 13 years ago • 3 comments

I just debugged my teams code for a specific IE9 bug. No matter what happened with the forms the $pristine $valid $dirty $error tags would not update when the form was within paragraph tags.

http://jsfiddle.net/totalknowledge/pm4pn/3/

totalknowledge avatar Aug 13 '13 17:08 totalknowledge

Form inside p paragraph is not allowed by the spec: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p

Narretz avatar Jan 22 '16 19:01 Narretz

I just read the entire spec. Not only does it not disallow the form element nested inside of a paragraph element, but an example on the w3c site specifically mentions a paragraph ending tag may be omitted if followed by a form element.

Tag omission in text/html: A p element's end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, div, dl, fieldset, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, nav, ol, p, pre, section, table, or ul, element, or if there is no more content in the parent element and the parent element is not an a element.

Also breaks with ng-form.

totalknowledge avatar Jan 22 '16 20:01 totalknowledge

According to my understanding of the spec (and according to most browsers implement this), a <form> element immediatelly following a <p> element, auto-closes the <p> element even if there is no closing tag. I.e.

<!-- The following: -->
<p><form ...><other-elements>...

<!-- Is equivalent to: -->
<p></p><form ...><other-elements>...

This is what other browsers do. IE9 incorrectly converts the first snippet to:

<p><form ...></form></p><other-elements>...

Thus, in IE9 the inputs and buttons do not appear in the DOM as child elements of the form, and can't affect its pristine, dirty, error etc state.

Closing as this is clearly an IE9 bug (i.e. happens without Angular too), and not something that Angular has any control over.

gkalpak avatar Jan 23 '16 12:01 gkalpak