Don't remove unreferenced defs if --keep-unreferenced-defs is specified (#62)
* Don't remove unreferenced defs if `--keep-unreferenced-defs` is specified (fixes #18) * Add unittests for previous commit
This commit is contained in:
parent
3299f8f6e0
commit
fe2884c3e8
3 changed files with 51 additions and 1 deletions
|
|
@ -623,7 +623,9 @@ def removeUnreferencedElements(doc, keepDefs):
|
|||
for id in identifiedElements:
|
||||
if not id in referencedIDs:
|
||||
goner = identifiedElements[id]
|
||||
if goner != None and goner.parentNode != None and goner.nodeName in removeTags:
|
||||
if (goner != None and goner.nodeName in removeTags
|
||||
and goner.parentNode != None
|
||||
and goner.parentNode.tagName != 'defs'):
|
||||
goner.parentNode.removeChild(goner)
|
||||
num += 1
|
||||
numElemsRemoved += 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue