crccheck / raphael-svg-import-classic

Import SVG files to Raphael
MIT License
98 stars 40 forks source link

"path" doesn't inherit "fill" attributte from groups #32

Open walokr opened 7 years ago

walokr commented 7 years ago

I've some troubles with "path" nodes inside "g". If "g" has a "fill", the "path" doesn't inherits the "fill" attribute.

I added these few lines between lines 65 and 66 of your code (you can test with this image: view-source:http://emojione.com/wp-content/uploads/assets/emojis/1f4a4.svg):

var groupFill =  elShape.getAttribute('fill');
        if (shapeName === "g" && groupFill) {
          var elShapeChildren = elShape.childNodes;
          for (i = 0, n = elShapeChildren.length; i < n; i++) {
            var elShapeChild = elShapeChildren[i];
            if (elShapeChild.nodeType === 1) {
                // add fill attribute
                elShapeChild.setAttribute('fill', groupFill);
            }
          }
        }
crccheck commented 7 years ago

oh wow, I didn't know people were still using this now that IE is pretty much dead! This seems like a simple addition. Thanks. Uhhh, I don't know when I'll get around to it but feel free to bug me about it. If I touch this, I have to be careful not to start touching everything.