svgdotjs / svg.easing.js

Easing equations for the fx module in the svg.js library
MIT License
53 stars 25 forks source link

Checking for SVG.supported flag #4

Open aforty opened 7 years ago

aforty commented 7 years ago

Hi, I'm having an issue in my testing environment. I include svg.js which early on does a test for whether svg's are supported in the current environment and exits out if they are not.

https://github.com/svgdotjs/svg.js/blob/04e21b18c30d546ed6a16b279504a2b58b503541/src/svg.js#L20

My issue is that svg.js will exit if not supported but svg.easing.js will not. svg.easing.js attempts to set SVG.easing[key] = easing[key] which fails because SVG.easing does not exist.

Would you accept a PR for a similar check for SVG.supported and exit the script the same way as svg.js does if it's not supported?

Fuzzyma commented 7 years ago

Sorry for the late reply! I wonder if this really would be neccesary. After all the code just throws an error but nothing breaks. It is ofc more clean when checking that before...hm...

aforty commented 7 years ago

I think it is necessary. If one is to use the proper method of importing depdencies via import then they cannot be wrapped in an if environment check (not to mention a try-catch). Therefore the same file cannot be run in a test environment that doesn't support SVG. Since svg.js includes this check then I think this extension script should too in order to be consistent.

Fuzzyma commented 7 years ago

The thing is, that this check would be needed in every svg.js plugin which is quite a bit of an overhead. Adding it here would mean we need to add it everywhere. I agree with you that it would be more consistent.