Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit82b971c

Browse files
committed
fixup! fixup! Preserve attribute order when parsing
1 parent752d847 commit82b971c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎html5lib/html5parser.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__importabsolute_import,division,unicode_literals
2-
fromsiximportwith_metaclass,viewkeys
2+
fromsiximportwith_metaclass,viewkeys,PY3
33

44
importtypes
55

@@ -2631,7 +2631,11 @@ def processEndTag(self, token):
26312631

26322632

26332633
defadjust_attributes(token,replacements):
2634-
ifviewkeys(token['data'])&viewkeys(replacements):
2634+
ifPY3orutils.PY27:
2635+
needs_adjustment=viewkeys(token['data'])&viewkeys(replacements)
2636+
else:
2637+
needs_adjustment=frozenset(token['data'])&frozenset(replacements)
2638+
ifneeds_adjustment:
26352639
token['data']=OrderedDict((replacements.get(k,k),v)
26362640
fork,vintoken['data'].items())
26372641

‎html5lib/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__importabsolute_import,division,unicode_literals
22

3+
importsys
34
fromtypesimportModuleType
45

56
fromsiximporttext_type
@@ -12,9 +13,11 @@
1213

1314
__all__= ["default_etree","MethodDispatcher","isSurrogatePair",
1415
"surrogatePairToCodepoint","moduleFactoryFactory",
15-
"supports_lone_surrogates"]
16+
"supports_lone_surrogates","PY27"]
1617

1718

19+
PY27=sys.version_info[0]==2andsys.version_info[1]>=7
20+
1821
# Platforms not supporting lone surrogates (\uD800-\uDFFF) should be
1922
# caught by the below test. In general this would be any platform
2023
# using UTF-16 as its encoding of unicode strings, such as

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp