Closed Bug 290481 Opened 19 years ago Closed 19 years ago

E4X: descendants method called on XMLList returns list with the elements in the original list being included

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla1.8beta2

People

(Reporter: martin.honnen, Assigned: brendan)

Details

(Keywords: js1.5)

Attachments

(2 files)

In my understanding calling the method descendants on an XMLList objects should
return a new XMLList with all the descendants of all the XML objects in the
original list. Spidermonkey however returns a list with all those descendants
but also includes the XML objects from the original list which I think is a bug.

Example test case:

var gods = <gods>
  <god>
    <name>Kibo</name>
  </god>
  <god>
    <name>Xibo</name>
  </god>
</gods>;

var godList = gods.god;
print('godList.length(): ' + godList.length());

for each (var xmlObject in godList) {
  print('nodeKind(): ' + xmlObject.nodeKind() + '; name(): ' + xmlObject.name());
}
print('');

var descendantList = godList.descendants();
print('descendantList.length(): ' + descendantList.length());

for each (var xmlObject in descendantList) {
  print('nodeKind(): ' + xmlObject.nodeKind() + '; name(): ' + xmlObject.name());
}


Output in Spidermonkey:

godList.length(): 2
nodeKind(): element; name(): god
nodeKind(): element; name(): god

descendantList.length(): 6
nodeKind(): element; name(): god
nodeKind(): element; name(): name
nodeKind(): text; name(): null
nodeKind(): element; name(): god
nodeKind(): element; name(): name
nodeKind(): text; name(): null

Output in Rhino (Rhino 1.6 release 1 2004 11 30)

godList.length(): 2
nodeKind(): element; name(): god
nodeKind(): element; name(): god

descendantList.length(): 4
nodeKind(): element; name(): name
nodeKind(): text; name(): null
nodeKind(): element; name(): name
nodeKind(): text; name(): null


I think the Rhino output is correct, there are four descendants, the two <name>
elements and the two text nodes inside of the <name> elements but the two <god>
elements should not be included in the descendants list.
Assignee: general → brendan
Flags: blocking1.8b2+
Keywords: js1.5
Priority: -- → P1
Target Milestone: --- → mozilla1.8beta2
Status: NEW → ASSIGNED
OS: Windows XP → All
Hardware: PC → All
I spaced out during the 7000+ line coding journey and didn't finish Descendants
by making it handle XMLList.

/be
Attachment #180835 - Flags: review+
Attachment #180835 - Flags: approval1.8b2+
Martin, thanks once again -- please keep filing bugs as fast as you find 'em ;-).

/be
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
updated test checked in:
Checking in 13.5.4.9.js;
/cvsroot/mozilla/js/tests/e4x/XMLList/13.5.4.9.js,v  <--  13.5.4.9.js
new revision: 1.4; previous revision: 1.3

test passed.
Status: RESOLVED → VERIFIED
Flags: testcase+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: