Tree construction: Ambiguity in "process the token as if the insertion mode was ..."

Consider a document like <table><tr><table>

After the first two tokens, we have:

Mode: in row
Current node: <tr>

then

Token: <table>
"in row" "Anything else" -> "Process the token as if the insertion mode 
was "in table""
New mode, for the duration of the reprocessing step: in table

     Token: <table>
     "in table" "A start tag whose tag name is "table"" -> "Act as if an 
end tag token with the tag name "table" had been seen"

     Token: </table>
     "in table" "An end tag whose tag name is "table"" -> "Generate 
implied end tags"
       -> current node is <tr>, so act as if </tr> and then generate 
implied end tags again

         Token: </tr>
         "in table" "An end tag whose tag name is one of: ..."tr"" -> 
"Ignore the token"

         Infinite loop when generating implied end tags again.

which is clearly not good. It seems my problem is in interpreting 
"Process the token as if the insertion mode was "in table"" as meaning 
it should effectively set the insertion mode to "in table" and then 
process the token (hence affecting any other generated/reprocessed 
tokens within that reprocessing step), when actually it should only 
affect the single next operation and not anything more deeply nested.


I'd suggest adding a paragraph like:

"When the steps below require the UA to process a token as if the 
insertion mode was 'mode', this must apply only to the single next token 
processing operation. If the processing of that token causes it to be 
reprocessed, or causes a new token to be processed, then it will be 
processed in the standard insertion mode and not necessarily in 'mode'."

and then linking to it in relevant places, like "process the token <a 
href='#asif'>as if the insertion mode was</a> ..."

-- 
Philip Taylor
pjt47@cam.ac.uk

Received on Friday, 15 February 2008 16:11:46 UTC