Closed Bug 355422 Opened 18 years ago Closed 13 years ago

E4X: Iterating over XML objects gives other type of objects

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: f.braem, Unassigned)

References

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7

When iterating over xml children the type of the object is not 'xml' when there is only one child.

Reproducible: Always

Steps to Reproduce:
var xml1 = <document>
            <properties>
             <property name="XML1-P1">XML1 Property 1</property>
             <property name="XML1-P2">XML1 Property 2</property>
            </properties>
           </document>;
var xml2 = <document>
            <properties>
             <property name="XML2-P1">XML2 Property 1</property>
            </properties>
           </document>;

wxJS.print("XML1");
for each (var property in xml1.properties['property'])
{
  wxJS.print(typeof property);
}

wxJS.print("XML2");
for each (var property in xml2.properties.child('property'))
{
  wxJS.print(typeof property);
}
Actual Results:  
22:10:23: XML1
22:10:23: xml
22:10:23: xml
22:10:23: XML2
22:10:23: string


Expected Results:  
22:10:23: XML1
22:10:23: xml
22:10:23: xml
22:10:23: XML2
22:10:23: xml

I've tested this with the latest source from CVS.
Summary: Iterating over XML objects gives other type of objects → E4X: Iterating over XML objects gives other type of objects
Seems to be the similar: https://bugzilla.mozilla.org/show_bug.cgi?id=355258
The issue here seems to come from XML objects having a property named '0' that is set to the same string as either toString() or toXMLString(). This testcase creates 2 XML objects and alerts property '0'.
Blocks: e4x
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: