[Javascript] accessing a <label>

liorean liorean at gmail.com
Mon Jun 4 08:24:20 CDT 2007


On 04/06/07, Troy III Ajnej <trojani2000 at hotmail.com> wrote:
> Yeah, sibling throuh whitespace and newline characters is a major
>  W3C flaw, those guys are a bunch of idiots. None of them browsers
>  out there will interpret empty characters or more than a single white-
>  space even if inside the defined html tag, than why on earth, or why
>  would he for any reason wanna count newlines on his source code?
>  What possible reason would they have to mess with DOM like that?

Because the DOM has no knowledge of the content model of the element.
For elements that have element-only content models it would have made
sense to have newlines and other insignificant whitespace removed from
the node tree. BUT, for any element with a mixed or text only content
model ALL whitespace is significant. If you had the source:

   <div>
        <span>This</span>
        <span>is</span>
        <span>some</span>
        <span>filer</span>
        <span>text</span>
        <span>just</span>
        <span>to</span>
        <span>prove</span>
        <span>my</span>
        <span>point</span>
    </div>

... should that look like this: "This is some filler text just to
prove my point." or should it look like this:
"Thisissomefillertextjusttoprovemypoint." The DOM doesn't know the
content model, so it's a question of which treatment is preferable -
removing ALL whitespace-only text nodes or removing NONE. The W3C
chose to not remove the whitespace-only nodes since that would be
wrong for any element with mixed content. Having the whitespace nodes
in the DOM on the other hand doesn't hurt any element-only content,
because they can safely be ignored in that context.

>  A simple bunch of idiots,...

And you should consider the possibility that they weren't idiots but
actually had a well considered reason for their choice...
-- 
David "liorean" Andersson



More information about the Javascript mailing list