From b1afa736a92be73f33d949e8f260fc7a20b743de Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Fri, 15 Apr 2005 20:32:15 +0000 Subject: [PATCH] Finish implementing Descendants, handle the neglected XMLList case (290481, r/a=me). --- js/src/jsxml.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/js/src/jsxml.c b/js/src/jsxml.c index a121912fb944..a1b83bdf4ca6 100644 --- a/js/src/jsxml.c +++ b/js/src/jsxml.c @@ -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;