drawsvg icon indicating copy to clipboard operation
drawsvg copied to clipboard

Filters with children like feMerge

Open thinkjson opened this issue 4 years ago • 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?

thinkjson avatar Jun 12 '21 11:06 thinkjson

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.

cduck avatar Jun 12 '21 17:06 cduck

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

thinkjson avatar Jun 12 '21 20:06 thinkjson

Yeah, doing this works for me.

class ParentFilterItem(FilterItem):
    hasContent = True

thinkjson avatar Jun 12 '21 20:06 thinkjson

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.

cduck avatar Jun 13 '21 01:06 cduck