jonathantneal / svg4everybody

Use external SVG spritemaps today
https://jonneal.dev/svg4everybody/
Other
3.29k stars 353 forks source link

2.1.5 is not working for SVGs loaded after intialization #143

Closed selbekk closed 7 years ago

selbekk commented 7 years ago

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 });
selbekk commented 7 years ago

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 :-)

timeiscoffee commented 7 years ago

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

timeiscoffee commented 7 years ago

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

selbekk commented 7 years ago

Yay! No problem - glad to help 😊