-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TS(Canvas): constructor optional el #9348
Conversation
Update StaticCanvas.ts
Build Stats
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// canvasEl === 'HTMLCanvasElement' does not work on jsdom/node | ||
const el = isHTMLCanvas(arg0) | ||
? arg0 | ||
: (getFabricDocument().getElementById(arg0) as HTMLCanvasElement) || | ||
: (arg0 && | ||
(getFabricDocument().getElementById(arg0) as HTMLCanvasElement)) || | ||
createCanvasElement(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is where the optional comes to play
Yes i always noticed that i had to pass a canvas even if i knew the code was able to just generate it. |
Motivation
TS
Description
It seems the el arg is optional (
new Canvas()
) so I typed is as such.Canvas is initialized like that in tests and in node.
Changes
Gist
In Action