iconfu/svg-inject

calling SVGInject multiple times on an img tag when src is updated

elwyos opened this issue · 1 comments

So my vue component gets updated data, and tries to call SVGInject on a previously SVGInjected element.

However, nothing happens.

The first time I call SVGInject (from vue's mounted event), everything works fine and the afterInject handler was invoked just fine.

However, when the component needs to change the src of the image, what I did was replace children with a cloned HTMLElement img node, and then call SVGInject to them.

This time, afterInject was not invoked, even though the return value promise finished, and onAllFinish also was invoked.

I end up with the img component with svg source, which means they don't follow CSS rules I set on the page.

Note the black icons:
image

What am I missing?

(thanks in advance)

Uh.. I guess I should have just dived at the source code. It was setting an attribute imgelement.__svgInject which I just had to = null in order to make it work again.