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

VERIFIED FIXED in mozilla1.8beta2

Status

()

Core
JavaScript Engine
P1
normal
VERIFIED FIXED
13 years ago
13 years ago

People

(Reporter: Martin Honnen, Assigned: brendan)

Tracking

({js1.5})

Trunk
mozilla1.8beta2
js1.5
Points:
---
Bug Flags:
blocking1.8b2 +
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

13 years ago
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.
(Reporter)

Comment 1

13 years ago
Created attachment 180805 [details]
test case to be run in Spidermonkey or Rhino shell
(Assignee)

Updated

13 years ago
Assignee: general → brendan
Flags: blocking1.8b2+
Keywords: js1.5
Priority: -- → P1
Target Milestone: --- → mozilla1.8beta2
(Assignee)

Updated

13 years ago
Status: NEW → ASSIGNED
OS: Windows XP → All
Hardware: PC → All
(Assignee)

Comment 2

13 years ago
Created attachment 180835 [details] [diff] [review]
fix, obvious from ECMA-357

I spaced out during the 7000+ line coding journey and didn't finish Descendants
by making it handle XMLList.

/be
(Assignee)

Updated

13 years ago
Attachment #180835 - Flags: review+
Attachment #180835 - Flags: approval1.8b2+
(Assignee)

Comment 3

13 years ago
Martin, thanks once again -- please keep filing bugs as fast as you find 'em ;-).

/be
Status: ASSIGNED → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → FIXED

Comment 4

13 years ago
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

Updated

13 years ago
Flags: testcase+
You need to log in before you can comment on or make changes to this bug.