W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2010

[whatwg] The form attribute (Association of controls and forms)

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 3 Aug 2010 23:38:18 +0000 (UTC)
Message-ID: <Pine.LNX.4.64.1008032337320.7470@ps20323.dreamhostps.com>
On Fri, 14 May 2010, Mounir Lamouri wrote:
> 
> "4.10.18 Association of controls and forms" explains the link between 
> forms and form-associated elements (and the form attribute). However, 
> I've the feeling the specifications go far over what should be done and 
> force the implementor how to do it. What I mean is, this could be 
> summarized like this: "If the form attribute is specified, the form 
> owner of the element is the first form in the Document with the id 
> corresponding of the form attribute value, if any. If the form attribute 
> content is not a form element id, the element has no form owner. If the 
> form attribute isn't specificed, the element form owner is the nearest 
> ancestor form."
> 
> However, the specification say (not only): "When a form-associated 
> element's ancestor chain changes, e.g. because it or one of its 
> ancestors was inserted or removed from a Document, then the user agent 
> must reset the form owner of that element.
> 
> When a form-associated element's form attribute is added, removed, or 
> has its value changed, then the user agent must reset the form owner of 
> that element.
> 
> When a form-associated element has a form attribute and the ID of any of 
> the elements in the Document changes, then the user agent must reset the 
> form owner of that form-associated element.
> 
> When a form-associated element has a form attribute and an element with 
> an ID is inserted into or removed from the Document, then the user agent 
> must reset the form owner of that form-associated element."
> 
> These sentences explain more than "what should be the form owner" but 
> explain how to implement it. It seems useless and maybe not needed 
> sometimes (I'm wondering if checking for the ID wouldn't be better than 
> observing all the element's ID change and insertion/removal).
> 
> In my opinion, the form attribute behaves more or less like the for 
> attribute for the label element so I'm wondering why the specification 
> is so different. Is there a reason I'm missing ?

This is unfortunately needed for historical reasons. It handles weird 
cases like:

   <div><form></div>
   <input>

...where the <input> or the <form> are later moved in the DOM.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 3 August 2010 16:38:18 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:59 UTC