svg.easing.js icon indicating copy to clipboard operation
svg.easing.js copied to clipboard

Checking for SVG.supported flag

Open aforty opened this issue 8 years ago • 3 comments

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?

aforty avatar May 12 '17 14:05 aforty

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...

Fuzzyma avatar Jun 26 '17 08:06 Fuzzyma

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.

aforty avatar Jun 26 '17 09:06 aforty

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.

Fuzzyma avatar Jun 30 '17 07:06 Fuzzyma