jonathantneal/svg4everybody

2.1.5 is not working for SVGs loaded after intialization

selbekk opened this issue · 4 comments

When updating from 2.1.4 to 2.1.5, our SVGs suddenly disappeared in IE11.

Not really sure if it's this or this commit that introduces this regression, but it looks to me like it's the latter.

We invoke your lib like this:

import svg4everybody from 'svg4everybody';

svg4everybody({ polyfill: true });

Looks like this line is the culprit.

The reason for this breaking things (for us) is that we have a SPA that first shows a spinner and then loads some new HTML (with SVGs).

When the script first starts up, the result of document.getElementsByType('use') returns 0, and 0 - 0 is not greater than zero. Therefore, the requestAnimationFrame is never called, which in turn never re-runs the onInterval function.

I'll create a PR :-)

Crap, thanks for fixing this. I'll merge and republish.

Thanks @selbekk, I just published v2.1.6 with your fix.

Yay! No problem - glad to help 😊