Closed
Bug 339047
Opened 19 years ago
Closed 19 years ago
XML.prototype.parent() returns undefined for lists with multiple parents
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: daumling, Unassigned)
Details
Assume a bookstore containing books, containing titles.
<bookstore>
<book>
<title>...</title>
</book>
...
</bookstore>
The following statement returns undefined:
xml.book.title.parent()
The standard does not mention this situation, but I would at least expect an empty XMLList. XPath returns a list containing all parents of all elements if the elements have multiple parents, and I think that this is a good solution.
XMLList.prototype.function::parents = function parents(){
var r = new XMLList();
for(var i=0; i < this.length(); i++) r += this[i].parent();
return r;
}
xml =
<bookstore>
<book>
<title>book 1</title>
</book>
<book>
<title>book 2</title>
</book>
<book>
<title>book 3</title>
</book>
</bookstore>
xml.book.title.parents()
//gives
<book>
<title>book 1</title>
</book>
<book>
<title>book 2</title>
</book>
<book>
<title>book 3</title>
</book>
Comment 2•19 years ago
|
||
(In reply to comment #0)
>
> The standard does not mention this situation,
It does -- see 13.5.4.16 in http://www.mozilla.org/js/language/ECMA-357.pdf.
/be
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
| Reporter | ||
Comment 3•19 years ago
|
||
Why cannot I read?
Withdrawn.
I am sure that there is a good reason to differ from XPath...
Comment 4•19 years ago
|
||
(In reply to comment #3)
> Why cannot I read?
>
> Withdrawn.
>
> I am sure that there is a good reason to differ from XPath...
I'm not, but this is an issue for ECMA TG1, when we have time for son-of-E4X with good use of the Edition 4 / JS2 type system. Let's call it E5X!
/be
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•