Prevent form-association when creating elements in template contents.

RESOLVED FIXED in mozilla26

Status

()

Core
HTML: Parser
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: wchen, Assigned: wchen)

Tracking

unspecified
mozilla26
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(2 attachments)

(Assignee)

Description

5 years ago
Update the <template> parser implementation to disallow form association of elements in template content. e.g.

<form><template><input></template></form>
<template><form><input></form></template>

The <input> elements should not be associated with the <form> elements.

http://html5.org/tools/web-apps-tracker?from=8114&to=8115
(Assignee)

Updated

5 years ago
Summary: Disallow form-association in template contents. → Prevent form-association when creating elements in template contents.
(Assignee)

Comment 1

5 years ago
Created attachment 784798 [details] [diff] [review]
Prevent form association when creating elements in template contents.

I ran into a related bug while working on the update. In the following markup:

<template><form><input></form></template>

According to the spec (http://www.whatwg.org/specs/web-apps/current-work/#association-of-controls-and-forms), the input should not be associated with the form element because it is not inserted into a document. However, this is not the case in Gecko because we do not check the "inserted into a document" bit.

I've excluded this case from my tests. I rather fix the issue in a follow-up bug since it is a different problem.
Attachment #784798 - Flags: review?(hsivonen)
(Assignee)

Comment 2

5 years ago
Created attachment 784799 [details] [diff] [review]
Tests to ensure form association does not occur when creating elements in template contents.
Attachment #784799 - Flags: review?(hsivonen)
Comment on attachment 784798 [details] [diff] [review]
Prevent form association when creating elements in template contents.

Does the "form == null || " bit add value? It looks like an unnecessary comparison to me. r+ in any case.
Attachment #784798 - Flags: review?(hsivonen) → review+
Attachment #784799 - Flags: review?(hsivonen) → review+
(Assignee)

Comment 4

5 years ago
(In reply to Henri Sivonen (:hsivonen) from comment #3)
> Comment on attachment 784798 [details] [diff] [review]
> Prevent form association when creating elements in template contents.
> 
> Does the "form == null || " bit add value? It looks like an unnecessary
> comparison to me. r+ in any case.

For majority of the cases, form == null and I wanted to short circuit isTemplateContents() because it looks through the stack. I wasn't sure if the compiler would be able to optimize it. In any case, it reads closer to the spec so I've left it in there.

https://hg.mozilla.org/integration/mozilla-inbound/rev/cc84be0b4a5d
https://hg.mozilla.org/mozilla-central/rev/cc84be0b4a5d

Is the test upstreamable?
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla26

Updated

5 years ago
Flags: needinfo?(wchen)
(Assignee)

Comment 6

5 years ago
(In reply to :Ms2ger from comment #5)
> https://hg.mozilla.org/mozilla-central/rev/cc84be0b4a5d
> 
> Is the test upstreamable?

I would say no because this test doesn't completely test the specified behavior. I left out some tests because I only fixed the parser piece but there is still a DOM piece that needs to be fixed.
Flags: needinfo?(wchen)
You need to log in before you can comment on or make changes to this bug.