From b8950a2eb11524d5038b3622ea2b07dacfba8435 Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Wed, 26 Jul 2006 20:49:52 +0000 Subject: [PATCH] Make XML.prototype.appendChild useful by fixing a bug in GetProperty that also exists in ECMA-357. bug 336921, r=brendan --- js/src/jsxml.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/js/src/jsxml.c b/js/src/jsxml.c index 6c6c66143454..afcb982a0b94 100644 --- a/js/src/jsxml.c +++ b/js/src/jsxml.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=4 sw=4 et tw=80: + * vim: set ts=4 sw=4 et tw=78: * * ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 @@ -4009,7 +4009,6 @@ retry: } else { list = (JSXML *) JS_GetPrivate(cx, listobj); list->xml_target = xml; - list->xml_targetprop = nameqn; for (i = 0, n = JSXML_LENGTH(xml); i < n; i++) { kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML); @@ -4064,7 +4063,6 @@ retry: } else { list = (JSXML *) JS_GetPrivate(cx, listobj); list->xml_target = xml; - list->xml_targetprop = nameqn; if (JSXML_HAS_KIDS(xml)) { if (OBJ_GET_CLASS(cx, nameobj) == &js_AttributeNameClass) { @@ -4097,6 +4095,14 @@ retry: if (!ok) return JS_FALSE; + /* + * Erratum: ECMA-357 9.1.1.1 misses that [[Append]] sets the given list's + * [[TargetProperty]] to the property that is being appended. This means + * that any use of the internal [[Get]] property returns a list which, + * when used by e.g. [[Insert]] duplicates the last element matched by id. + * See bug 336921. + */ + list->xml_targetprop = nameqn; *vp = OBJECT_TO_JSVAL(listobj); return JS_TRUE; }