- From: Ian Hickson <ian@hixie.ch>
- Date: Sat, 24 May 2008 09:03:22 +0000 (UTC)
- To: Henri Sivonen <hsivonen@iki.fi>
- Cc: HTML WG <public-html@w3.org>
On Fri, 4 Apr 2008, Henri Sivonen wrote:
> >
> > An end tag token not covered by the previous entries [...]
>
> I think the above formulation is confusing, because it runs through
> complicated steps in the simple case: when the node on the stack indeed
> matches the token.
When the token matches the current node, the steps are:
1. Let node = current node
2. If node == token:
2.1. Generate implied end tags (no-op, current node doesn't have
an impliable end tag).
2.2. If current node != token: n/a
2.3. Pop node.
Abort.
I guess that's mildly more complicated than necessary, but it's hardly
"complicated steps". Still, UAs can trivially optimise it by adding:
If current node == token:
Pop node. Abort.
...to the top of the algorithm, without affecting black box conformance in
any way.
> It seems to me that the whole purpose of the complication (searching
> stack first and then batch-popping instead of popping as the search
> proceeds) is to give on error about premature end tag instead of giving
> many error one per each unclosed element.
Partially, but it's also to avoid the bug your code has:
> > if (isCurrent(name)) {
> > pop();
> > return;
> > }
> > for(;;) {
> > generateImpliedEndTags();
> > if (isCurrent(name)) {
> > pop();
> > return;
> > }
> > StackNode<T> node = stack[currentPtr];
> > if (!(node.scoping || node.special)) {
> > err("Unclosed element \u201C" + node.name
> > + "\u201D.");
> > pop();
> > } else {
> > err("Stray end tag \u201C" + name
> > + "\u201D.");
> > return;
> > }
> > }
What does your code do with this?:
<div><p>Hello</x> World
I tried testing it with parsetree.validator.nu but it failed more than I
expected:
http://parsetree.validator.nu/?doc=http%3A%2F%2Fjunkyard.damowmow.com%2F323&submit=Print+Tree
However, from reading the code above, it looks like your code will close
the <p>. It shouldn't close anything unless a tag is matched.
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Received on Saturday, 24 May 2008 09:04:04 UTC