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

Commit62e3436

Browse files
author
James Graham
committed
Fix button scoping stuff
1 parent81c4a5d commit62e3436

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

‎html5lib/constants.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@
310310

311311
specialElements=frozenset((
312312
(namespaces["html"],"address"),
313+
(namespaces["html"],"applet"),
313314
(namespaces["html"],"area"),
314315
(namespaces["html"],"article"),
315316
(namespaces["html"],"aside"),
@@ -320,6 +321,7 @@
320321
(namespaces["html"],"body"),
321322
(namespaces["html"],"br"),
322323
(namespaces["html"],"button"),
324+
(namespaces["html"],"caption"),
323325
(namespaces["html"],"center"),
324326
(namespaces["html"],"col"),
325327
(namespaces["html"],"colgroup"),
@@ -346,6 +348,7 @@
346348
(namespaces["html"],"head"),
347349
(namespaces["html"],"header"),
348350
(namespaces["html"],"hr"),
351+
(namespaces["html"],"html"),
349352
(namespaces["html"],"iframe"),
350353
# Note that image is commented out in the spec as "this isn't an
351354
# element that can end up on the stack, so it doesn't matter,"
@@ -356,12 +359,14 @@
356359
(namespaces["html"],"li"),
357360
(namespaces["html"],"link"),
358361
(namespaces["html"],"listing"),
362+
(namespaces["html"],"marquee"),
359363
(namespaces["html"],"menu"),
360364
(namespaces["html"],"meta"),
361365
(namespaces["html"],"nav"),
362366
(namespaces["html"],"noembed"),
363367
(namespaces["html"],"noframes"),
364368
(namespaces["html"],"noscript"),
369+
(namespaces["html"],"object"),
365370
(namespaces["html"],"ol"),
366371
(namespaces["html"],"p"),
367372
(namespaces["html"],"param"),
@@ -371,15 +376,19 @@
371376
(namespaces["html"],"section"),
372377
(namespaces["html"],"select"),
373378
(namespaces["html"],"style"),
379+
(namespaces["html"],"table"),
374380
(namespaces["html"],"tbody"),
381+
(namespaces["html"],"td"),
375382
(namespaces["html"],"textarea"),
376383
(namespaces["html"],"tfoot"),
384+
(namespaces["html"],"th"),
377385
(namespaces["html"],"thead"),
378386
(namespaces["html"],"title"),
379387
(namespaces["html"],"tr"),
380388
(namespaces["html"],"ul"),
381389
(namespaces["html"],"wbr"),
382-
(namespaces["html"],"xmp")
390+
(namespaces["html"],"xmp"),
391+
(namespaces["svg"],"foreignObject")
383392
))
384393

385394
spaceCharacters=frozenset((

‎html5lib/html5parser.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def startswithany(str, prefixes):
4040
importutils
4141
importconstants
4242
fromconstantsimportspaceCharacters,asciiUpper2Lower
43-
fromconstantsimportscopingElements,formattingElements,specialElements
43+
fromconstantsimportformattingElements,specialElements
4444
fromconstantsimportheadingElements,tableInsertModeElements
4545
fromconstantsimportcdataElements,rcdataElements,voidElements
4646
fromconstantsimporttokenTypes,ReparseException,namespaces,spaceCharacters
@@ -1015,12 +1015,12 @@ def startTagFrameset(self, token):
10151015
self.parser.phase=self.parser.phases["inFrameset"]
10161016

10171017
defstartTagCloseP(self,token):
1018-
ifself.tree.elementInScope("p"):
1018+
ifself.tree.elementInScope("p",variant="button"):
10191019
self.endTagP(impliedTagToken("p"))
10201020
self.tree.insertElement(token)
10211021

10221022
defstartTagPreListing(self,token):
1023-
ifself.tree.elementInScope("p"):
1023+
ifself.tree.elementInScope("p",variant="button"):
10241024
self.endTagP(impliedTagToken("p"))
10251025
self.tree.insertElement(token)
10261026
self.parser.framesetOK=False
@@ -1030,7 +1030,7 @@ def startTagForm(self, token):
10301030
ifself.tree.formPointer:
10311031
self.parser.parseError(u"unexpected-start-tag", {"name":"form"})
10321032
else:
1033-
ifself.tree.elementInScope("p"):
1033+
ifself.tree.elementInScope("p",variant="button"):
10341034
self.endTagP(impliedTagToken("p"))
10351035
self.tree.insertElement(token)
10361036
self.tree.formPointer=self.tree.openElements[-1]
@@ -1047,24 +1047,24 @@ def startTagListItem(self, token):
10471047
self.parser.phase.processEndTag(
10481048
impliedTagToken(node.name,"EndTag"))
10491049
break
1050-
if (node.nameTuplein(scopingElements|specialElements)and
1050+
if (node.nameTupleinspecialElementsand
10511051
node.namenotin ("address","div","p")):
10521052
break
10531053

1054-
ifself.tree.elementInScope("p"):
1054+
ifself.tree.elementInScope("p",variant="button"):
10551055
self.parser.phase.processEndTag(
10561056
impliedTagToken("p","EndTag"))
10571057

10581058
self.tree.insertElement(token)
10591059

10601060
defstartTagPlaintext(self,token):
1061-
ifself.tree.elementInScope("p"):
1061+
ifself.tree.elementInScope("p",variant="button"):
10621062
self.endTagP(impliedTagToken("p"))
10631063
self.tree.insertElement(token)
10641064
self.parser.tokenizer.state=self.parser.tokenizer.plaintextState
10651065

10661066
defstartTagHeading(self,token):
1067-
ifself.tree.elementInScope("p"):
1067+
ifself.tree.elementInScope("p",variant="button"):
10681068
self.endTagP(impliedTagToken("p"))
10691069
ifself.tree.openElements[-1].nameinheadingElements:
10701070
self.parser.parseError("unexpected-start-tag", {"name":token["name"]})
@@ -1116,15 +1116,15 @@ def startTagAppletMarqueeObject(self, token):
11161116
self.parser.framesetOK=False
11171117

11181118
defstartTagXmp(self,token):
1119-
ifself.tree.elementInScope("p"):
1119+
ifself.tree.elementInScope("p",variant="button"):
11201120
self.endTagP(impliedTagToken("p"))
11211121
self.tree.reconstructActiveFormattingElements()
11221122
self.parser.framesetOK=False
11231123
self.parser.parseRCDataRawtext(token,"RAWTEXT")
11241124

11251125
defstartTagTable(self,token):
11261126
ifself.parser.compatMode!="quirks":
1127-
ifself.tree.elementInScope("p"):
1127+
ifself.tree.elementInScope("p",variant="button"):
11281128
self.processEndTag(impliedTagToken("p"))
11291129
self.tree.insertElement(token)
11301130
self.parser.framesetOK=False
@@ -1143,7 +1143,7 @@ def startTagParamSource(self, token):
11431143
token["selfClosingAcknowledged"]=True
11441144

11451145
defstartTagHr(self,token):
1146-
ifself.tree.elementInScope("p"):
1146+
ifself.tree.elementInScope("p",variant="button"):
11471147
self.endTagP(impliedTagToken("p"))
11481148
self.tree.insertElement(token)
11491149
self.tree.openElements.pop()
@@ -1402,8 +1402,7 @@ def endTagFormatting(self, token):
14021402
afeIndex=self.tree.openElements.index(formattingElement)
14031403
furthestBlock=None
14041404
forelementinself.tree.openElements[afeIndex:]:
1405-
if (element.nameTuplein
1406-
specialElements|scopingElements):
1405+
ifelement.nameTupleinspecialElements:
14071406
furthestBlock=element
14081407
break
14091408
# Step 3
@@ -1525,8 +1524,7 @@ def endTagOther(self, token):
15251524
pass
15261525
break
15271526
else:
1528-
if (node.nameTuplein
1529-
specialElements|scopingElements):
1527+
ifnode.nameTupleinspecialElements:
15301528
self.parser.parseError("unexpected-end-tag", {"name":token["name"]})
15311529
break
15321530

‎html5lib/treebuilders/_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def elementInScope(self, target, variant=None):
132132
# Exit early when possible.
133133
listElementsMap= {
134134
None:scopingElements,
135+
"button":scopingElements|set([(namespaces["html"],"button")]),
135136
"list":scopingElements|set([(namespaces["html"],"ol"),
136137
(namespaces["html"],"ul")]),
137138
"table":set([(namespaces["html"],"html"),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp