@@ -388,7 +388,7 @@ def resetInsertionMode(self):
388
388
nodeName = self .innerHTML
389
389
# Check for conditions that should only happen in the innerHTML
390
390
# case
391
- if nodeName in ("select" , "colgroup" , "head" , "frameset" , " html" ):
391
+ if nodeName in ("select" , "colgroup" , "head" , "html" ):
392
392
assert self .innerHTML
393
393
394
394
if nodeName in newModes :
@@ -1385,7 +1385,11 @@ def endTagFormatting(self, token):
1385
1385
# http://www.whatwg.org/specs/web-apps/current-work/#adoptionAgency
1386
1386
# XXX Better parseError messages appreciated.
1387
1387
name = token ["name" ]
1388
- while True :
1388
+
1389
+ outerLoopCounter = 0
1390
+ while outerLoopCounter < 8 :
1391
+ outerLoopCounter += 1
1392
+
1389
1393
# Step 1 paragraph 1
1390
1394
formattingElement = self .tree .elementInActiveFormattingElements (
1391
1395
token ["name" ])
@@ -1435,16 +1439,17 @@ def endTagFormatting(self, token):
1435
1439
1436
1440
# Step 6
1437
1441
lastNode = node = furthestBlock
1438
- while True :
1439
- # AT replace this with a function and recursion?
1442
+ innerLoopCounter = 0
1443
+
1444
+ index = self .tree .openElements .index (node )
1445
+ while innerLoopCounter < 3 :
1446
+ innerLoopCounter += 1
1440
1447
# Node is element before node in open elements
1441
- node = self .tree .openElements [
1442
- self .tree .openElements .index (node )- 1 ]
1443
- while node not in self .tree .activeFormattingElements :
1444
- tmpNode = node
1445
- node = self .tree .openElements [
1446
- self .tree .openElements .index (node )- 1 ]
1447
- self .tree .openElements .remove (tmpNode )
1448
+ index -= 1
1449
+ node = self .tree .openElements [index ]
1450
+ if node not in self .tree .activeFormattingElements :
1451
+ self .tree .openElements .remove (node )
1452
+ continue
1448
1453
# Step 6.3
1449
1454
if node == formattingElement :
1450
1455
break
@@ -1454,7 +1459,6 @@ def endTagFormatting(self, token):
1454
1459
+ 1 )
1455
1460
# Step 6.5
1456
1461
#cite = node.parent
1457
- #if node.hasContent():
1458
1462
clone = node .cloneNode ()
1459
1463
# Replace node with clone
1460
1464
self .tree .activeFormattingElements [
0 commit comments