document.getElementsByTagName does not recurse through document tree

VERIFIED INVALID

Status

()

Firefox
General
VERIFIED INVALID
13 years ago
13 years ago

People

(Reporter: Anthony Glenwright, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

13 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6 (ax)

document.getElementsByTagName does not recurse through the document elements, 
it only returns top-level children of the document.

Reproducible: Always

Steps to Reproduce:
1.  Browse to any web page (www.w3.org)
2.  Open the Javascript console
3.  Enter document.getElementsByTagName('*').length or 
document.getElementsByTagName('div').length.  


Actual Results:  
document.getElementsByTagName('*').length returns "4"
document.getElementsByTagName('div').length returns "0"

Expected Results:  
document.getElementsByTagName('*').length should return a number in the 
hundreds (for each element on the page).
document.getElementsByTagName('div').length should return > 10 (I didn't count 
the number of DIV tags on www.w3.org, but it's more than 0)

This also happens in code, but I'm including only the Javscript console method 
of verifying as a minimal test case.
(Reporter)

Comment 1

13 years ago
I didn't mention - this happens in 1.0.4 and 1.0.6

Comment 2

13 years ago
When you evaluate those expressions _in the javascript console_ you are
evaluating them in the context of the console, not the currently open web page.
If you open a web page (e.g, www.w3.org) and paste 

javascript:document.getElementsByTagName('*').length

into the URL bar and hit enter you will see something like 505 in Mozilla 1.7.10
etc.

INVALID.

Status: UNCONFIRMED → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → INVALID
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.