Find valid parent element when collapsing result content
Previously if a result element marked for collapsing didn't have a valid "parent" element, the collapsing was skipped altogether. This loops through child elements until a valid parent is found (or if one isn't found, the element will not be collapsed).main
parent
958faed1b6
commit
38c38a772f
|
@ -173,8 +173,12 @@ class Filter:
|
|||
break
|
||||
|
||||
# Create the new details element to wrap around the result's
|
||||
# immediate parent
|
||||
parent = result_children[0].parent
|
||||
# first parent
|
||||
parent = None
|
||||
idx = 0
|
||||
while not parent and idx < len(result_children):
|
||||
parent = result_children[idx].parent
|
||||
idx += 1
|
||||
details = BeautifulSoup(features='html.parser').new_tag('details')
|
||||
summary = BeautifulSoup(features='html.parser').new_tag('summary')
|
||||
summary.string = label
|
||||
|
|
Loading…
Reference in New Issue