8000 <link>, <base> and <meta> are no longer moved to <head>, unless in ve… · awesome-python/html5lib-python@50f68b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 50f68b2

Browse files
committed
<link>, <base> and <meta> are no longer moved to <head>, unless in very special cases
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40779
1 parent 4e4c2a4 commit 50f68b2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/html5parser.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,11 @@ def startTagScript(self, name, attributes):
595595

596596
def startTagBaseLinkMeta(self, name, attributes):
597597
element = self.tree.createElement(name, attributes)
598-
self.appendToHead(element)
598+
if (self.tree.headPointer is not None and
599+
self.parser.phase == self.parser.phases["inHead"]):
600+
self.appendToHead(element)
601+
else:
602+
self.tree.openElements[-1].appendChild(element)
599603

600604
def startTagOther(self, name, attributes):
601605
self.anythingElse()
@@ -692,9 +696,9 @@ def __init__(self, parser, tree):
692696

693697
self.startTagHandler = utils.MethodDispatcher([
694698
("html", self.startTagHtml),
695-
(("script", "style"), self.startTagScriptStyle),
696-
(("base", "link", "meta", "title"),
697-
self.startTagFromHead),
699+
(("base", "link", "meta", "script", "style"),
700+
self.startTagProcessInHead),
701+
("title", self.startTagTitle),
698702
("body", self.startTagBody),
699703
(("address", "blockquote", "center", "dir", "div", "dl",
700704
"fieldset", "listing", "menu", "ol", "p", "pre", "ul"),
@@ -779,10 +783,10 @@ def processCharacters(self, data):
779783
self.tree.reconstructActiveFormattingElements()
780784
self.tree.insertText(data)
781785

782-
def startTagScriptStyle(self, name, attributes):
786+
def startTagProcessInHead(self, name, attributes):
783787
self.parser.phases["inHead"].processStartTag(name, attributes)
784788

785-
def startTagFromHead(self, name, attributes):
789+
def startTagTitle(self, name, attributes):
786790
self.parser.parseError(_(u"Unexpected start tag (" + name +\
787791
") that belongs in the head. Moved."))
788792
self.parser.phases["inHead"].processStartTag(name, attributes)

0 commit comments

Comments
 (0)
0