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

Commitf6c2703

Browse files
author
James Graham
committed
Make reset insertion mode work right + fix InSelect to match
1 parent542dc08 commitf6c2703

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

‎html5lib/html5parser.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ def resetInsertionMode(self):
375375
# The name of this method is mostly historical. (It's also used in the
376376
# specification.)
377377
last=False
378+
foreign=False
378379
newModes= {
379380
"select":"inSelect",
380381
"td":"inCell",
@@ -388,38 +389,36 @@ def resetInsertionMode(self):
388389
"table":"inTable",
389390
"head":"inBody",
390391
"body":"inBody",
391-
"frameset":"inFrameset"
392+
"frameset":"inFrameset",
393+
"html":"beforeHead"
392394
}
393395
fornodeinself.tree.openElements[::-1]:
394396
nodeName=node.name
397+
new_phase=None
395398
ifnode==self.tree.openElements[0]:
399+
assertself.innerHTML
396400
last=True
397-
ifnodeNamenotin ['td','th']:
398-
# XXX
399-
assertself.innerHTML
400-
nodeName=self.innerHTML
401+
nodeName=self.innerHTML
401402
# Check for conditions that should only happen in the innerHTML
402403
# case
403-
ifnodeNamein ("select","colgroup","head","frameset"):
404-
# XXX
404+
ifnodeNamein ("select","colgroup","head","frameset","html"):
405405
assertself.innerHTML
406+
406407
ifnodeNameinnewModes:
407-
self.phase=self.phases[newModes[nodeName]]
408+
new_phase=self.phases[newModes[nodeName]]
408409
break
409410
elifnode.namespacein (namespaces["mathml"],namespaces["svg"]):
410-
self.phase=self.phases["inForeignContent"]
411-
self.secondaryPhase=self.phases["inBody"]
412-
break
413-
elifnodeName=="html":
414-
ifself.tree.headPointerisNone:
415-
self.phase=self.phases["beforeHead"]
416-
else:
417-
self.phase=self.phases["afterHead"]
418-
break
411+
foreign=True
419412
eliflast:
420-
self.phase=self.phases["inBody"]
413+
new_phase=self.phases["inBody"]
421414
break
422415

416+
ifforeign:
417+
self.phase=self.phases["inForeignContent"]
418+
self.secondaryPhase=new_phase
419+
else:
420+
self.phase=new_phase
421+
423422
defparseRCDataRawtext(self,token,contentType):
424423
"""Generic RCDATA/RAWTEXT Parsing algorithm
425424
contentType - RCDATA or RAWTEXT
@@ -2195,7 +2194,8 @@ def __init__(self, parser, tree):
21952194
("option",self.startTagOption),
21962195
("optgroup",self.startTagOptgroup),
21972196
("select",self.startTagSelect),
2198-
(("input","keygen","textarea"),self.startTagInput)
2197+
(("input","keygen","textarea"),self.startTagInput),
2198+
("script",self.startTagScript)
21992199
])
22002200
self.startTagHandler.default=self.startTagOther
22012201

@@ -2241,6 +2241,9 @@ def startTagInput(self, token):
22412241
self.endTagSelect(impliedTagToken("select"))
22422242
self.parser.phase.processStartTag(token)
22432243

2244+
defstartTagScript(self,token):
2245+
self.parser.phases["inHead"].processStartTag(token)
2246+
22442247
defstartTagOther(self,token):
22452248
self.parser.parseError("unexpected-start-tag-in-select",
22462249
{"name":token["name"]})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp