[whatwg] Citing multiple <blockquote> elements in HTML5

On Tue, 2 Dec 2008, Calogero Alex Baldacchino wrote:
>
> Indeed it does, and I found such behaviour more consistent than letting 
> just the a element with a 'name' or an 'id' being an anchor for 
> navigating to a fragment :-)
> 
> However, now I have a question. The 3rd step of the algorithm to 
> determine "the indicated part of the document" says,
> 
> "If there is an element in the DOM that has an ID exactly equal to 
> /fragid/, then the first such element in tree order is the indicated 
> part of the document; stop the algorithm here."
> 
> Shouldn't the id be unique in the whole document? Section 3.3.3.2 says,
>
> "The||| id |attribute represents its element's unique identifier. The 
> value must be unique in the subtree within which the element finds 
> itself and must contain at least one character. The value must not 
> contain any space characters."
> 
> then follows,
> 
> "If the value is not the empty string, user agents must associate the 
> element with the given value (exactly, including any space characters) 
> [...]"
> 
> First of all, isn't it a bit conflicting? Space characters are legal or 
> not?

They are not legal. Duplicate IDs are similarly not legal.

We still have to define what happens when people break the rules, though, 
it happens all the time.


> "for the purposes of ID matching within the subtree the element finds 
> itself (e.g. for selectors in CSS or for the |getElementById()| method 
> in the DOM)."
> 
> I guess the above covers, for instance, the case of a document holding 
> an element with id="foo" and an iframe whose content document holds 
> another element with the very same id; but speaking about subtrees might 
> suggest the following is legal:
> 
> <body>
> <div><p id="foo">something</p><p>something else</p></div>
> <div><p>something else from <cite id="foo">Whatever Example</cite></p></div>
> </body>
> 
> since we can separate two different subtrees where the id 'foo' is unique.

Both of those IDs are in the same subtree, so it's not legal.


> Otherwise, just let the id attribute be unique in the whole document, 
> label any duplicate one as illegal and treat it as the empty string, so 
> that one only method is enough and the DOM 3 undefined behaviour for 
> 'getElementById' is no more problematic, being fired by non-allowed DOM 
> structures (as don't care conditions). Such would be the easiest choice, 
> although there might be any good reason to prefer allowing replicated 
> ids inside the same document.

Exactly how getElementById() works is out of scope for HTML5, but in the 
Web DOM Core spec that Simon is working on I imagine he has specced that 
it will pick the first element with a matching ID or some such behavior.

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

Received on Tuesday, 2 December 2008 17:32:21 UTC