svgdotjs / svg.js

The lightweight library for manipulating and animating SVG
https://svgjs.dev
Other
11.04k stars 1.08k forks source link

Runner.js uses object property rest - which is not supported by IE and Edge - resulting in : SCRIPT1028: Expected identifier, string or number #1027

Closed jeyben closed 4 years ago

jeyben commented 5 years ago

Bug report

My angular application is using svgjs (se versions below): "@angular/animations": "8.0.0", "@angular/common": "8.0.0", "@angular/compiler": "8.0.0", "@angular/core": "8.0.0", "@angular/forms": "8.0.0", "@angular/platform-browser": "8.0.0", "@angular/platform-browser-dynamic": "8.0.0", "@angular/router": "8.0.0", "@svgdotjs/svg.js": "^3.0.13" ... When running my application in an IE Edge browser I get the following error: "SCRIPT1028: Expected identifier, string or number"

And it refers to: Runner.js:765 let target = new Matrix({ ...transforms, origin: [ x, y ] })

The reason is that the code uses object property rest, which isn´t supported by IE or Edge, hence the library and the application using it, won´t run in IE and Edge browsers :-(

jeyben commented 5 years ago

According to stackoverflow, it seems to be an issue with IE not supporting object property rest: https://stackoverflow.com/questions/53628191/edge-script1028-expected-identifier-string-or-number

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Browser_compatibility

To have IE and Edge support for svgjs, the syntax of the function needs to be rewritten

j040p3d20 commented 4 years ago

My angular app was importing the module and after compilation i was having same error. I replaced the import with declaring a global declare const SVG:any and imported the compiled script into my angular.json . Now its working. I got it from this answer

Fuzzyma commented 4 years ago

With the new transpiled bundle for esm this should work in all supported browsers now

jeyben commented 4 years ago

It works! Thanks!