mikeric / rivets

Lightweight and powerful data binding.
http://rivetsjs.com
MIT License
3.23k stars 310 forks source link

svg sprite (xlink:href) render problem #716

Open laphilosophia opened 6 years ago

laphilosophia commented 6 years ago

Hi all.

I call icons in the project using the svg sprite method. But the icon does not appear when rivets render. I could not find a solution what I did. there is any solution, you know about that? (sorry about my english)

Here is the sample code: (with pug) svg(class="icon view-icon") use(rv-xlink:href="item.icon")

and the rendered result: `

shadow dom (closed)` ~ nothing :(

ultradeq commented 6 years ago

Hi, I had the same problem and solved it with custom binder:

rivets.binders.xlinkhref = function(el, value) {
    el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', '#' + value)
}

HTML:

<svg class="icon view-icon">
    <use rv-xlinkhref="item.icon"></use>
</svg>