@@ -334,6 +334,7 @@ def resetInsertionMode(self):
334
334
elif node .namespace in (namespaces ["mathml" ], namespaces ["svg" ]):
335
335
self .phase = self .phases ["inForeignContent" ]
336
336
self .secondaryPhase = self .phases ["inBody" ]
337
+ break
337
338
elif nodeName == "html" :
338
339
if self .tree .headPointer is None :
339
340
self .phase = self .phases ["beforeHead" ]
@@ -1146,7 +1147,8 @@ def startTagMath(self, token):
1146
1147
self .tree .insertElement (token )
1147
1148
#Need to get the parse error right for the case where the token
1148
1149
#has a namespace not equal to the xmlns attribute
1149
- self .parser .secondaryPhase = self .parser .phase
1150
+ if self .parser .phase != self .parser .phases ["inForeignContent" ]:
1151
+ self .parser .secondaryPhase = self .parser .phase
1150
1152
self .parser .phase = self .parser .phases ["inForeignContent" ]
1151
1153
if token ["selfClosing" ]:
1152
1154
self .tree .openElements .pop ()
@@ -1160,7 +1162,8 @@ def startTagSvg(self, token):
1160
1162
self .tree .insertElement (token )
1161
1163
#Need to get the parse error right for the case where the token
1162
1164
#has a namespace not equal to the xmlns attribute
1163
- self .parser .secondaryPhase = self .parser .phase
1165
+ if self .parser .phase != self .parser .phases ["inForeignContent" ]:
1166
+ self .parser .secondaryPhase = self .parser .phase
1164
1167
self .parser .phase = self .parser .phases ["inForeignContent" ]
1165
1168
if token ["selfClosing" ]:
1166
1169
self .tree .openElements .pop ()
@@ -2175,6 +2178,10 @@ def __init__(self, parser, tree):
2175
2178
Phase .__init__ (self , parser , tree )
2176
2179
2177
2180
def nonHTMLElementInScope (self ):
2181
+ for element in self .tree .openElements [::- 1 ]:
2182
+ if<
E4FC
/span> element .namespace == self .tree .defaultNamespace :
2183
+ return self .tree .elementInScope (element )
2184
+ assert False
2178
2185
for item in self .tree .openElements [::- 1 ]:
2179
2186
if item .namespace == self .tree .defaultNamespace :
2180
2187
return True
@@ -2240,11 +2247,9 @@ def processStartTag(self, token):
2240
2247
currentNode .name in frozenset (["foreignObject" ,
2241
2248
"desc" , "title" ])
2242
2249
)):
2243
- print currentNode , token , self .nonHTMLElementInScope ()
2244
- print self .tree .openElements
2245
2250
assert self .parser .secondaryPhase != self
2246
2251
self .parser .secondaryPhase .processStartTag (token )
2247
- if self .parser .phase == self and not self .nonHTMLElementInScope ():
2252
+ if self .parser .phase == self and self .nonHTMLElementInScope ():
2248
2253
self .parser .phase = self .parser .secondaryPhase
2249
2254
elif token ["name" ] in self .breakoutElements :
2250
2255
self .parser .parseError ("unexpected-html-element-in-foreign-content" ,
@@ -2268,8 +2273,9 @@ def processStartTag(self, token):
2268
2273
token ["selfClosingAcknowledged" ] = True
2269
2274
2270
2275
def processEndTag (self , token ):
2276
+ self .adjustSVGTagNames (token )
2271
2277
self .parser .secondaryPhase .processEndTag (token )
2272
- if self .parser .phase == self and not self .nonHTMLElementInScope ():
2278
+ if self .parser .phase == self and self .nonHTMLElementInScope ():
2273
2279
self .parser .phase = self .parser .secondaryPhase
2274
2280
2275
2281
class AfterBodyPhase (Phase ):
0 commit comments