Fix loop and support area tag

It appears the output of qtwebkit has a cycle, so we end in an endless
loop. This limits the loop to 5 steps.
This commit is contained in:
Kevin Velghe 2016-03-31 00:58:19 +02:00
parent 0432ba68c6
commit 0fe0f84546

View File

@ -288,8 +288,11 @@ class WebElementWrapper(collections.abc.MutableMapping):
def remove_blank_target(self):
"""Remove target from link."""
elem = self._elem
while elem is not None:
if elem.tagName().lower() == 'a':
for i in range(5):
if elem is None:
break
tag = elem.tagName().lower()
if tag == 'a' or tag == 'area':
if elem.attribute('target') == '_blank':
elem.setAttribute('target', '_top')
break