svgdotjs / svg.filter.js

A plugin for svg.js adding svg filters
MIT License
218 stars 52 forks source link

Class constructor Element cannot be invoked without 'new' #55

Open edemaine opened 2 years ago

edemaine commented 2 years ago

I'm getting the following error when trying to build a basic filter

svg.filter.js:16 Uncaught TypeError: Class constructor Element cannot be invoked without 'new'
    at new Filter (svg.filter.js:16)
    at Defs.filter (svg.filter.js:316)
    at Use.filterWith (svg.filter.js:336)

I don't understand why this error occurs, because svg.filter.js:316 clearly has a new:

var filter = this.put(new Filter())

My code:

robot.filterWith((add) =>
  add.colorMatrix('hueRotate', 0))

(robot is an SVG.Use object.)

package.json dependencies:

  "dependencies": {
    "@svgdotjs/svg.filter.js": "^3.0.7",
    "@svgdotjs/svg.js": "^3.0.16"
  }

HTML:

<script src="node_modules/@svgdotjs/svg.js/dist/svg.min.js"></script>
<script src="node_modules/@svgdotjs/svg.filter.js/dist/svg.filter.js"></script>

Am I missing something obvious?

Fuzzyma commented 2 years ago

I think the transpilation step might mess up stuff here. Maybe I have to update the toolchain and rebuild. You can try using the esm versions. That should work

edemaine commented 2 years ago

Sounds good. As my filter needs were simple, I've switched to using .animate().during() and setting CSS filters for now, so no rush for me. But thought it might be helpful to know the situation.

Fuzzyma commented 2 years ago

I released a new version with an updated build chain. Hopefully that fixes it