Gracefully handle unreferenced gradients with --keep-unreferenced-defs (#173)

Closes: #156
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2018-03-10 16:06:50 +01:00 committed by Eduard Braun
parent cae0faefa0
commit 6ea126d290

View file

@ -1421,6 +1421,10 @@ def removeDuplicateGradients(doc):
# for each element that referenced the gradient we are going to replace dup_id with master_id
dup_id = dupGrad.getAttribute('id')
funcIRI = re.compile('url\\([\'"]?#' + dup_id + '[\'"]?\\)') # matches url(#a), url('#a') and url("#a")
# With --keep-unreferenced-defs, we can end up with
# unreferenced gradients. See GH#156.
if dup_id in referencedIDs:
for elem in referencedIDs[dup_id]:
# find out which attribute referenced the duplicate gradient
for attr in ['fill', 'stroke']: