Skip to content

Commit 84c1206

Browse files
committed
Don't needlessly scramble attribute order while walking an etree
1 parent c18094a commit 84c1206

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

html5lib/treewalkers/etree.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
from __future__ import absolute_import, division, unicode_literals
22

3+
try:
4+
from collections import OrderedDict
5+
except ImportError:
6+
try:
7+
from ordereddict import OrderedDict
8+
except ImportError:
9+
OrderedDict = dict
310
import gettext
411
_ = gettext.gettext
512

@@ -61,7 +68,7 @@ def getNodeDetails(self, node):
6168
else:
6269
namespace = None
6370
tag = node.tag
64-
attrs = {}
71+
attrs = OrderedDict()
6572
for name, value in list(node.attrib.items()):
6673
match = tag_regexp.match(name)
6774
if match:

0 commit comments

Comments
 (0)