Re: [whatwg] Form-associated elements and the parser

On Tue, 6 Aug 2013, Adam Klein wrote:
> Hixie opened my eyes last week to parser-association behavior of the 
> sort found at 
> In that case, an <input> in a detached tree is associated with a <form> 
> in the main document. This causes badness in WebKit and Blink because 
> the association between the <form> and the <input> (e.g., as exposed in 
> the HTMLFormElement.elements collection) is only weakly held to avoid 
> reference loops (and thus memory leaks). And that weakness occasionally 
> results in crashes when one of these objects is collected before the 
> other.
> While all modern HTML parser implementations I tested seemed to agree on 
> their treatment of the above example (they all return "1" as 
> elements.length), this feature doesn't strike me as terribly useful. And 
> for what it's worth, it doesn't seem to be present in legacy IE.
> I'm interested what others would think about changing the parser to only 
> associate a <form> with an <input> if both are in the same "home 
> subtree" Or is there some deep web-compat reason for this parsing 
> oddity?

On Tue, 6 Aug 2013, Jonas Sicking wrote:
> Sure, as long as you come up with a formalized algorithm for when there 
> is an association and when there isn't. Keep in mind that by the time 
> that the input-element is inserted, the form-element might have been 
> moved elsewhere. We likely don't need the association in that case, but 
> detecting that that has happened sounds tricky.

On Tue, 6 Aug 2013, Adam Klein wrote:
> My concrete proposal would be something like this:
> In step 4 of [create an element for the token], add a requirement that 
> "intended parent" and the "form element pointer" be part of the same 
> "home subtree" [...]

I think this works... there's some dodginess around how elements are 
inserted in the AAA, but I think it works there as well.

(The 'reset the form owner' algorithm can't associate cross-subtree; only 
the parser can do this. So it's just the parser that needs fixing.)

Ian Hickson               U+1047E                )\._.,--....,'``.    fL       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Monday, 16 September 2013 17:35:53 UTC