Finish implementing Descendants, handle the neglected XMLList case (290481, r/a=me).

This commit is contained in:
brendan%mozilla.org 2005-04-15 20:32:15 +00:00
parent 1270d4f310
commit b1afa736a9

View File

@ -3378,7 +3378,8 @@ Descendants(JSContext *cx, JSXML *xml, jsval id)
jsid funid;
JSXMLQName *nameqn;
JSObject *listobj;
JSXML *list;
JSXML *list, *kid;
uint32 i, n;
JSBool ok;
nameqn = ToXMLName(cx, id, &funid);
@ -3401,7 +3402,18 @@ Descendants(JSContext *cx, JSXML *xml, jsval id)
list->name = nameqn;
if (!JS_EnterLocalRootScope(cx))
return NULL;
ok = DescendantsHelper(cx, xml, nameqn, list);
if (xml->xml_class == JSXML_CLASS_LIST) {
for (i = 0, n = xml->xml_kids.length; i < n; i++) {
kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);
if (kid->xml_class == JSXML_CLASS_ELEMENT) {
ok = DescendantsHelper(cx, kid, nameqn, list);
if (!ok)
break;
}
}
} else {
ok = DescendantsHelper(cx, xml, nameqn, list);
}
JS_LeaveLocalRootScope(cx);
if (!ok)
return NULL;