Empty text node in DOM tree
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <5d67800c-4070-4062-b458-47756134344b@f47g2000hsd.googlegroups.com> |
I noticed that after Mozilla loads a document, it creates empty text
node between tags that have new line character in between. A lot of
other DOM applications do the same thing. However, the problem in
Mozilla case is this behavior is a bit random, at least from my point
of view. Here is a simple HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<title>Title here</title>
<style>
h1 {
color: blue;
}
</style>
</head>
<body>
<input type="hidden" name="test" value="1">
<p>A paragraph</p>
</body>
</html>
A logical guess will be Mozilla creates an empty text node per new
line between tags. The actual result is: there is always an empty text
node after <head> (even if the new line were removed between <head>
and <meta>; there is always no empty text node between <meta> and
<title> (even if I added spaces after <meta>); there is an empty text
node between <title> and <style>; under the <body> subtree, it seems
like there is one empty text node per new line, but I am not sure for
more complexed document.
Does Mozilla treat tags differently regarding the new line between
them? Is there a specification for the parsing behavior? Appreciate if
someone can point me there. Thanks.