Closed Bug 17026 Opened 26 years ago Closed 26 years ago

DOM is unable to see objects

Categories

(Core :: DOM: Core & HTML, defect, P3)

All
Windows 98
defect

Tracking

()

VERIFIED INVALID

People

(Reporter: jcarpenter0524, Assigned: vidur)

Details

Attachments

(5 files)

Overview Description: In the attached test case DOM is unable to see the [object Text] Note: If you run this test in viewer, you will see the correct result initially, however if you then reload viewer you will see the "null" result instead. It doesn't seem to matter what object I use here, text was just simplest. Steps to Reproduce: - Run attached test case in Apprunner - Note result is "null" Actual Results: null Expected Results: [object Text] Build Date & Platform Bug Found: Win98 1999102111 Additional Builds and Platforms Tested On: MacPPC, Linux Additional Information:
QA Contact: gerardok → janc
Attached file attaching testcase
I don't know why the attachments aren't working, here's the source: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>test</TITLE> <SCRIPT TYPE="text/javascript" SRC="../testlib.js"></SCRIPT> </HEAD> <BODY> Hi Mom. <SCRIPT TYPE="text/javascript"> var oList=document.firstChild.childNodes[1].childNodes[0]; document.write(oList); </SCRIPT> </BODY> </HTML>
Severity: blocker → major
Lowering Severity from blocker to major.
Summary: [BLOCKER]DOM is unable to see objects → DOM is unable to see objects
Attached file another testcase
Weird. The attached testcase shows the following output in Linux x86 build 1999102608 on Red Hat 6.0: ---------- Whatever. Name 0: {HEAD} Value 0: {} Name 1: {#text} Value 1: { } Name 2: {BODY} Value 2: {} ---------- There seems to be a "phantom" text node between the BODY and HEAD elements. So, in janc's example code, doing: <SCRIPT TYPE="text/javascript"> var oList=document.firstChild.childNodes[2].childNodes[0]; // ......................................^ note 2 instead of 1 document.write(oList); </SCRIPT> would find the "Hi Mom." text node.
Status: NEW → RESOLVED
Closed: 26 years ago
Resolution: --- → INVALID
I'm not sure I see the problem here. The TextNode visible at document.firstChild.childNodes[1] is the whitespace between the HEAD and the BODY. The DOM spec allows such whitespace to be preserved, even if it isn't significant. I'm surprised at Jan's comment that she got inconsistent results. The result were always the same for me - the null of result of looking at the childNodes of the whitespace Text node. Marking INVALID - it works as I would expect. As chadh mentions, the BODY element (if that's what you're looking for) is document.firstChild.childNodes[2] (or, better yet, document.body).
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
The problem is that I should indeed find the "Hi Mom" text node, but don't. I expect to see "[text node]" But instead I was seeing "null". In today's build (1999102808) the document.write statement produces nothing at all. I grabbed a random old build (1999090310), ran this test, and I do see the "[text node]" as expected. Is this a bug or has something been changed that makes my test invalid?
janc, I'm guessing older builds didn't preserve the whitespace between HEAD and BODY as a child node of HTML, so document.firstChild.childNodes[1] was the BODY element in your testcase. In more recent builds, [1] is the whitespace text node, and document.firstChild.childNodes[2] is the BODY (in your testcase). As vidur suggests, the test should probably use document.body rather than document.firstChild.childNodes[n] to refer to the BODY element.
Severity: major → normal
chadh, I agree that document.body would be a better way to go, however, shouldn't document.firstChild.childNodes[2].childNodes[1] work? I've tried this and also just taking my original code and removing all whitespace so that the code is all one line. Nothing is working.
Hmm ... that should be: document.firstChild.childNodes[2].childNodes[0] .............................................^ 0, not 1 which displays: Hi Mom. [object Text] in Linux x86 build 1999110108. I'll attach the modified testcase.
Attached file modified testcase
Interesting. Even when there's no whitespace between HEAD and BODY, e.g. </head><body> there is *still* a Text node being generated. The following HTML: ==================== <html> <head> <title>Bug 17026 - no WS between HEAD and BODY</title> </head><body> (No whitespace between HEAD and BODY elements.) <pre> <script type="text/javascript"> var fc = document.firstChild; for (var i = 0; i < 3; i++) { document.write("Name " + i + ": {" + fc.childNodes[i].nodeName + "}\n"); document.write("Value " + i + ": {" + fc.childNodes[i].nodeValue + "}\n"); } </script> </pre> </body> </html> ==================== produces this: (No whitespace between HEAD and BODY elements.) Name 0: {HEAD} Value 0: {} Name 1: {#text} Value 1: { } Name 2: {BODY} Value 2: {} The DOM spec allows whitespace to be preserved, but this seems to be a case of inserting whitespace where there is none. Bug?
Status: REOPENED → RESOLVED
Closed: 26 years ago26 years ago
Resolution: --- → INVALID
Gak! I swear I tried that yesterday and it didn't work! Today it does (much to my relief, and I'm sure to yours as well.) Thank you. Marking invalid and closing bug.
Status: RESOLVED → VERIFIED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: