Closed Bug 228213 Opened 21 years ago Closed 21 years ago

document.getElementsByTagName("*") returns incorrect number of elements.

Categories

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

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: mno2go, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007

Here is some code that I used to test this on:

<div id="div1">Test</div>
<div id="div6">Test</div>
<div id="div5">Test</div>
<div id="div4">Test</div>
<div id="div3">Test</div>
<div id="div2">Test</div>

I've trimmed all the other standard HTML page elements. When running the
following JavaScript:

var allel = document.getElementsByTagName("*");
alert (allel.length);

I was returned 5 elements in the popup. There are 6 divs. IE 6 handles this
correctly.

Reproducible: Always

Steps to Reproduce:
1.
2.
3.
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040125

I got 10 from this code:
html, head, body, script, 6:divs

I'm not sure why you did this... if i replace * w/ div then i get 6 as expected...
Assignee: general → general
Severity: major → normal
Component: JavaScript Engine → DOM: Core
QA Contact: pschwartau → ian
Max could you please re-test your code in the latest builds? The code you posted
in the URL returns 10 (correctly), and if I write a html file only with the 6
divs then do a javascript:url with 
javascript:alert(document.getElementsByTagName("*").length)
then I get 9 (correctly).
It seems to be working properly now. I don't know what caused the issue back
when I reported it.
Thanks for the followup, Max. Marking worksforme per the reporter's comments.
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → WORKSFORME
Anytime. It might have been fixed along the way. I just tested the code on the
original build on a different computer, and I saw the bug. :)
Component: DOM: Core → DOM: Core & HTML
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.