3
I am trying to define an Iron-iconset-svg using the icons with the Symbol tag instead of using the g tag and the icon is not rendered. In all documentation and references on the internet the SVG is used with the tag g. Exists
Follows excerpt from the code:
<iron-iconset-svg name="br-icons">
<svg style="display: none">
<defs>
<symbol id="icon-menu" viewBox="0 0 1024 1024">
<title>menu</title>
<path class="path1" d="M64 192h896v192h-896zM64 448h896v192h-896zM64 704h896v192h-896z"></path>
</symbol>
</defs>
</svg>
</iron-iconset-svg>
Follow the call to the component:
<iron-icon icon="br-icons:icon-menu"></iron-icon>
Does anyone have any idea how I can do that?
When I do this inside the component it only works if I pass the icon id directly. In case I am passing it via component attribute. <use xlink:href$="{{icon}}"></use> It renders the id in html but does not display the icon
– cbfranca
@cbfranca If it injects id into html less badly, checks whether in the <use></use> tag you are placing the coordinates X and Y. Ex: <use xlink:href="#icon-1" x="10" y ="40"></use>, I believe it needs this reference to show the element.
– dic-chen
I’m not passing no, but if I understood correctly, it would be 0.0 in this case: <Symbol id="icon-menu" viewBox="0 0 1024 1024">
– cbfranca
The strange thing is that if I pass the id of the icon directly it works. But if I pass via Polymer attribute n works. <svg> <use xlink:href$="{{icon}}" x="0" y="0"></use> </svg> <svg> <use xlink:href="#icon-user" x="0" y="0"></use> </svg>
– cbfranca
Take the viewBox attribute from the <Symbol> tag and leave it only for the svg container of the elements, as in the code above. If you did the test by placing the id directly and it worked there is no reason not to render once you recover that same value and play to the id attribute of your id element== "id value" -> {{injected value}}
– dic-chen
Nothing. It seems to me to be something related to the same Polymer. I am searching here but I did not find anything related.
– cbfranca