SVG display:none in style attribute


#1

Depending on the export format (I guess) of SVG in Illustrator, it places “display:none” in the style attribute when an item is not visible: e.g.,

<circle id="THUMB" style="display:none;fill:#822B5F;stroke:#591212;stroke-miterlimit:10;" cx="120.96" cy="100" r="8.71"/>

Of course, this isn’t picked up by the test for the “display” attribute being “none” in SVGState:: setCommonAttributes().

Each sub element needs to have its “style” attribute checked for this. Here’s a suggested change to SVGState::parseSubElements() to accommodate this:

void parseSubElements (const XmlPath& xml, DrawableComposite& parentDrawable)
{
    forEachXmlChildElement (*xml, e)
    {
        const XmlPath child (xml.getChild (e));
        Drawable* const drawable = parseSubElement (child);
        parentDrawable.addChildComponent (drawable);
        
        if (! getStyleAttribute (child, "display").trim().equalsIgnoreCase ("none"))
            drawable->setVisible (true);
    }
}

#2

Cheers, good catch, will add that…


#3

It’s also missing one edge case if the whole svg element has display:none in its attributes (as this doesn’t pass through that parseSubElements() function). But I wonder why anyone would save a file with the whole thing hidden!?