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

Commitd151e42

Browse files
committed
fixup! Preserve attribute order when parsing
Add a parser test for duplicate attributes; fix.
1 parente847f22 commitd151e42

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

‎html5lib/html5parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def normalizeToken(self, token):
265265
""" HTML5 specific normalizations to the token stream """
266266

267267
iftoken["type"]==tokenTypes["StartTag"]:
268-
token["data"]=OrderedDict(token['data'])
268+
token["data"]=OrderedDict(token['data'][::-1])
269269

270270
returntoken
271271

‎html5lib/tests/test_parser2.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ def test_unicode_file(self):
5151
parser=html5parser.HTMLParser()
5252
parser.parse(io.StringIO("a"))
5353

54+
deftest_duplicateAttribute(self):
55+
# This is here because we impl it in parser and not tokenizer
56+
parser=html5parser.HTMLParser()
57+
doc=parser.parse('<p class=a class=b>')
58+
el=doc[1][0]
59+
self.assertEqual(el.get("class"),"a")
60+
5461

5562
defbuildTestSuite():
5663
returnunittest.defaultTestLoader.loadTestsFromName(__name__)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp