hustcc/jest-canvas-mock

Q: where to go for DOMMatrix.invertSelf support

monfera opened this issue · 5 comments

DOMMatrix.invertSelf and the other DOMMatrix functions are super useful for working with objects that Canvas2d context functions use natively. Where do people get it from? I'm running things in current Jest, and get an Error: Uncaught [Error: Not implemented]

Specifically I use it via

const { a, d } = ctx.getTransform().invertSelf().scale(ctx.canvas.width, ctx.canvas.height)

My guess is that both jest-canvas-mock and jsdom have a DOMMatrix representation, but

  • jest-canvas-mock doesn't implement DOMMatrix.invertSelf because it's NOT a method on the canvas context
  • the jest-canvas-mock version of DOMMatrix is of course different from the jsdom one, and jsdom of course has no idea that it should "take over"

Oblig. banana gorilla problem

First and foremost, we are "mocking" an environment, so things like this are going to happen.

Let's fix this today.

@jtenner today was a long time ago :)
need help with it? would a PR be appreciated?

Hey I appreciate the sarcasm. My work here was a best ditch effort from me as a newbie developer, and I'm sorry for not having enough time to re-contribute back to this project.

As for help with the project, I'm sure this project could always use a pull request.