Subj : Re: E4X: result of parent() method call on XMLList To : Martin.Honnen From : Brendan Eich Date : Sat Apr 16 2005 05:22 pm Martin Honnen wrote: > > > Martin Honnen wrote: > >> The E4X specification says that undefined should be returned on >> calling parent() on an empty XMLList but Spidermonkey returns null. >> The errata (https://bugzilla.mozilla.org/attachment.cgi?id=169406) >> already mentions the discrepancy. >> Is there any decision by now what should be returned, null or undefined? > > > Spidermonkey behaves differently than I state above, for an empty > XMLList it indeed returns undefined but for the following XMLList it > returns null while the spec would mandate undefined too: > > js> var godList = <>KiboXibo; > js> print(godList.parent()) > null > > Rhino returns undefined. Sorry, my last reply was typed as I saw only your first post (Thunderbird really should scroll all new messages into view, if they fit -- anyone know of a bug on that?). Anyway, why do you say the spec mandates undefined? Here is the XMLList.prototype.parent algorithm in full: 1. If l.[[Length]] = 0, return undefined 2. Let parent = l[0].[[Parent]] 3. For i = 1 to l.[[Length]]-1, if l[i].[[Parent]] is not equal to parent, return undefined 4. Return parent Note that both elements have null as parent, so step 4 will return parent, which is l[0].[[Parent]] or null. Somone please file a Rhino bug. /be .