Closed Bug 485324 Opened 15 years ago Closed 11 years ago

HTMLCollection/NodeList prototype problem

Categories

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

1.9.1 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: bugzilla33, Unassigned)

Details

Attachments

(2 files)

User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b3) Gecko/20090305 Firefox/3.1b3

HTML Collection prototype problem


Reproducible: Always

Steps to Reproduce:
1. Run HTMLCollection.html from attachement
2. Should alert value: 2
3. Try on IE 8.0 - works perfect

Actual Results:  
Error: document.getElementsByTagName("div").indexOf is not a function
Source File: file:///C:/HTMLCollection.html
Line: 14


Expected Results:  
alert value: 2
Attached file HTMLCollection
Component: General → JavaScript Engine
Product: Firefox → Core
Version: unspecified → 1.9.1 Branch
Assignee: nobody → general
URL: n/a
QA Contact: general → general
Behaviour of .prototype (and its relationship to further-delegating objects) isn't standardized anywhere -- why do you believe that we should have IE8's behaviour here, out of curiosity?  This is a dup of something, I think related to getElementsByClassName, but I can't recall it off-hand.
Assignee: general → nobody
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → DOM: Core & HTML
Ever confirmed: true
QA Contact: general → general
I think now that getElementsByTagName shoudl return NodeList (not HTMLCollection)

Konqueror, Safari, Opera, Chrome return NodeList. Only IE returns HTMLCollection.

But FF NodeList also fails!

if(!NodeList.prototype.indexOf)NodeList.prototype.indexOf=function(V,I){for(I=I||0;I<this.length;I++)if(this[I]===V)return I;return -1}
Summary: HTML Collection prototype problem → HTMLCollection prototype problem
Summary: HTMLCollection prototype problem → HTMLCollection/NodeList prototype problem
Attachment #369461 - Attachment description: source → HTMLCollection
Attached file NodeList
Assuming getElementsByTagName() was meant to return an HTMLCollection, then it would be the fact that HTML 5 defines HTMLCollection using Web IDL that would require particular behaviour of .prototype.  (Web IDL admittedly isn't quite baked yet, but I think it's likely that requiring window.HTMLCollection.prototype be the collection object's [[Prototype]], and for the prototype object to be mutable like the test assumes, would survive.)

I suppose someone would need to write a version of DOM Core using Web IDL to get similar requirements for NodeList (perhaps http://simon.html5.org/specs/web-dom-core will be that).
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: