Skip to content

Commit 64e8b0b

Browse files
kovidgoyalgsnedders
authored andcommitted
Handle attributes from multiple body tags
1 parent 124e975 commit 64e8b0b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

html5lib/html5parser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,9 +1019,7 @@ def startTagBody(self, token):
10191019
assert self.parser.innerHTML
10201020
else:
10211021
self.parser.framesetOK = False
1022-
for attr, value in token["data"].items():
1023-
if attr not in self.tree.openElements[1].attributes:
1024-
self.tree.openElements[1].attributes[attr] = value
1022+
self.tree.apply_body_attributes(token['data'])
10251023

10261024
def startTagFrameset(self, token):
10271025
self.parser.parseError("unexpected-start-tag", {"name": "frameset"})

html5lib/treebuilders/_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ def apply_html_attributes(self, attrs):
274274
if attr not in self.openElements[0].attributes:
275275
self.openElements[0].attributes[attr] = value
276276

277+
def apply_body_attributes(self, attrs):
278+
for attr, value in attrs.items():
279+
if attr not in self.tree.openElements[1].attributes:
280+
self.tree.openElements[1].attributes[attr] = value
281+
277282
def _getInsertFromTable(self):
278283
return self._insertFromTable
279284

0 commit comments

Comments
 (0)