PolymerElements / iron-iconset-svg

Represents a source of icons expressed as a collection of inline SVGs
https://www.webcomponents.org/element/PolymerElements/iron-iconset-svg
37 stars 34 forks source link

createIconMap returns lots of non-icons when a complex icon contains paths with ids #41

Open danishdynamite opened 8 years ago

danishdynamite commented 8 years ago

I was writing a demo page for a custom iconset and was puzzled when it returned lots of stuff that was not icons at all.

It turns out the selector just looks for any element with an id-attribute, and I think that's a bit too lax. After I adjusted it to defs > g[id], it worked as I had expected it to, but then again, I don't know if this may ruin other stuff. Any comments?

    _createIconMap: function() {
      var icons = Object.create(null);
      Polymer.dom(this).querySelectorAll('defs > g[id]')
        .forEach(function(icon) {
          icons[icon.id] = icon;
        });
      return icons;
    },
karolchmist commented 7 years ago

We have the same problem when using svg with masks. Masks are referenced by ids and it pollutes the id space.