Skip to content

Commit 53bf191

Browse files
committed
Slight fixes to active formatting elements
1 parent d05574a commit 53bf191

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/html5lib/treebuilders/_base.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,22 @@ def reconstructActiveFormattingElements(self):
166166

167167
# Step 6
168168
while entry != Marker and entry not in self.openElements:
169-
# Step 5: let entry be one earlier in the list.
170169
i -= 1
171-
try:
172-
entry = self.activeFormattingElements[i]
173-
except:
174-
# Step 4: at this point we need to jump to step 8. By not doing
175-
# i += 1 which is also done in step 7 we achieve that.
170+
if i < 0:
171+
# Step 4: at this point we need to jump to step 8.
172+
# So we reset the index to 0 and break
173+
i += 1
176174
break
175+
# Step 5: let entry be one earlier in the list.
176+
entry = self.activeFormattingElements[i]
177+
177178
while True:
178179
# Step 7
179180
i += 1
180181

181182
# Step 8
182-
clone = self.activeFormattingElements[i].cloneNode()
183+
entry = self.activeFormattingElements[i]
184+
clone = entry.cloneNode() #Mainly to get a new copy of the attributes
183185

184186
# Step 9
185187
element = self.insertElement({"type":"StartTag",

0 commit comments

Comments
 (0)