2012-04-04 40 views
0

标准指定关于索引序列与NamedNodeMap对象内的Attr对象有什么关系?NamedNodeMap对象内的Attr对象索引问题

我在firefox和chrome中获得了反向序列。

<form action="test.php" method="post" name="test_form" id="test_form"> 

element = document.getElementById("test_form"); 
element.attributes.item(0); 
element.attributes.item(1); 
element.attributes.item(2); 
element.attributes.item(3); 

火狐:

id="test_form" 
name="test_form" 
method="post" 
action="test.php" 

铬:

action="test.php" 
method="post" 
name="test_form" 
id="test_form" 

回答

2

Documentation说:

NamedNodeMaps不能保存在任何特定的顺序。包含在实现NamedNodeMap的对象中的对象 也可以通过序号索引访问 ,但这仅仅是为了方便 枚举NamedNodeMap的内容,并不意味着DOM指定了这些节点的顺序。

所以,没有排序。