cduck/drawsvg

Filters with children like feMerge

thinkjson opened this issue · 4 comments

I'm using a variety of effects that require merging filter nodes in an feMerge. FilterItem currently prevents this because it has hasContent set to false. Setting this to true seems to allow filter nodes to be nested, and doesn't seem to have any other detrimental effects. Is there a reason this was set to false to begin with?

cduck commented

For any element that is a subclass of DrawingParentElement, hasContent = False only disables children and throws that error. This is intended to warn against incorrect SVGs but looks to be incorrect for several filter item tags.

It looks like the hasContent = False line should be removed or a new class should be defined for each filter item with the correct hasContent setting.

I suppose for my purposes, I could just subclass it and flip that flag, eh?

Yeah, doing this works for me.

class ParentFilterItem(FilterItem):
    hasContent = True
cduck commented

FilterItem.hasContent = True would also work.

If you make a pull request fixing it, I'll merge it and publish a new version within a few days.