[whatwg] Error in HTML parsing spec

The "Anything else" case of the in_table insertion mode of the HTML 
parsing spec reads:
> Process the token using the rules for the "in body" insertion mode, 
> except that if the current node is a table, tbody, tfoot, thead, or tr 
> element, then, whenever a node would be inserted into the current 
> node, it must instead be foster parented.
I think that this is actually incorrect (or at least very misleading) as 
it is worded.  In order to get correct parsing results, it appears that 
you have to do this:

Process the token using the rules for the "in body" insertion mode, 
except that whenever a node would be inserted into the current node and 
the current node is a table, tbody, tfoot, thead, or tr element, then 
the node to be inserted must instead be foster parented.

As the spec is currently worded, we are directed to check once whether 
the current node is a table, table section or table row, and then 
proceed to use the rules for the in body mode.  In fact, however, it is 
necessary to check whether the current node is a table, section or row 
each time a node is to be inserted.  This came up for me when a text 
node is being inserted into a table when there is an active formatting 
element that gets reconstructed and foster parented.  My reading of the 
current spec text said that the text node should also be foster parented 
(because I only checked whether the current node was a table once), and 
the text node ended up as a sibling of the active formatting element 
rather than a child of that element.

     David

Received on Friday, 14 October 2011 19:28:22 UTC