g_tag_is_unmergeable: consider <g> tags with ids unmergeable
If someone gave it an ID and we have not stripped it, then it is probably important and can alter the output somehow if we fiddle merge it into another node (or discard the <g> node with an ID). Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
eb582fe44c
commit
7e917c9ca0
1 changed files with 5 additions and 1 deletions
|
|
@ -1017,8 +1017,12 @@ def removeDescriptiveElements(doc, options):
|
|||
def g_tag_is_unmergeable(node):
|
||||
"""Check if a <g> tag can be merged or not
|
||||
|
||||
<g> tags with a title or descriptions should generally be left alone.
|
||||
Generally, there are two types of <g> tags that should be left alone:
|
||||
* <g> tags with a title or descriptions
|
||||
* <g> tags that has an ID
|
||||
"""
|
||||
if node.getAttribute('id') != '':
|
||||
return True
|
||||
return any(True for n in node.childNodes if n.nodeType == Node.ELEMENT_NODE
|
||||
and n.nodeName in ('title', 'desc') and n.namespaceURI == NS['SVG'])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue