-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
CheckList
- I agree to follow this project's Code of Conduct
- I have read and followed the Contributing Guide
- I have read and followed the Issue Tracker Guide
- I have searched and referenced existing issues and discussions
- I am filing a BUG report.
- I have managed to reproduce the bug after upgrading to the latest version
- I have created an accurate and minimal reproduction
Version
6.0.2
In What environments are you experiencing the problem?
Node.js
Node Version (if applicable)
20.0.0
Link To Reproduction
Description should be sufficient (references to specific code given)
Steps To Reproduce
- Create an Image using
node-canvas
- Pass it to the
FabricImage
constructor
import { Image } from 'canvas';
const nodeCanvasImage = new Image();
const fabricImage = new FabricImage(nodeCanvasImage);
Expected Behavior
Similar to this bug report I would expect, that passing a node-canvas Image object still works. We were using fabric.js together with node-canvas
for our node backends as previously described in the docs here. It would be nice to be able to use the node-canvas Image without stubbing/monkey patching the classList
property as before. And also without adding js-dom
just for this use case. What do you think?
Actual Behavior
The constructor of FabricImage will call Image.setElement()
, which tries to call the classList.add()
method on the passed image. The classList is only supported by HTMLImageElement
and not node-canvas Image. This will result in the following runtime error: Cannot read properties of undefined (reading 'add')
.
Error Message & Stack Trace
No response