[whatwg] [WA1] Missing step in formatting element algorithm

I've hit another issue in trying to getting the Adoption Agency Algorithm
working.  The issue arises with the following fragments:

<body><b> ab <em><div> cd </b>
<body><b> ab <u> xy <em><div> cd </b>

The algorithm attempts to insert nodes that already have a parent node into
another node.  Does the instruction to insert a node carry an implication
that you must first detach the node from its parent node, if it has one? If
so, that should either be documented at the start of the whole section, or
additional steps put into the algorithm to make it so.  Steps 5 and 10 are
much more explicit about detaching nodes from their parents.

The problem is triggered by the EM having a single child - that being the
DIV (the furthest block) that gets detached by step 5.  Consequently, in
step 7.4, 'node' (EM) does not have any children.  Thus in step 7.5, the DIV
is re-inserted into the original EM and we carry on around the steps in step
7 until we hit 7.2 where the two examples' behaviours diverge.

In the first example, 7.2 terminates the loop and we hit step 8, where: last
node is the EM; node is the B; and furthest block is the DIV. The condition
holds, so we are instructed to insert the EM into the BODY.  However, the EM
is still a child node of the B at this point.

In the second example, 7.4 clones the U and then (in 7.5) tries to insert
the EM into that clone whilst the EM is still a child of the original U.


Either the EM has to be cloned, or it has to be detached first.  The detach
first works better, I think, otherwise you end up with a useless EM leaf
node, which I guess is what 7.4's condition is trying to avoid in the first
place.


Also, what is "nearest block" for?  It's not used anywhere.  It looks like
it could be a remnant of an earlier version of the algorithm that didn't
have a step 14 that looped the whole algorithm, perhaps?  I think you can
strike the first paragraph of step 3, and move the second paragraph of step
3 into step 4, and remove the sentence "There will always be one ..." from
step 4, then delete step 3 completely.


-- 
Stewart Brodie
Software Engineer
ANT Software Limited

Received on Friday, 21 July 2006 09:12:55 UTC