Skip to content

Problem with RC and jsdom #2390

@brettz9

Description

@brettz9

Issue or Feature

Not sure whether you'll treat this as a jsdom issue (in case jsdom has to change its API or something), but with the RC release, jsdom no longer works.

Steps to Reproduce

With jsdom version 24.1.0

import jsdom from 'jsdom';

const {window: {document}} = new jsdom.JSDOM('');

const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');

...gives:

/Users/brett/typeson-registry/node_modules/.pnpm/[email protected][email protected]/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js:116
  ctx[name] = function (image, ...rest) {
            ^

TypeError: Cannot assign to read only property 'createPattern' of object '#<CanvasRenderingContext2D>'
    at wrapNodeCanvasMethod (/Users/brett/typeson-registry/node_modules/.pnpm/[email protected][email protected]/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js:116:13)
    at HTMLCanvasElementImpl.getContext (/Users/brett/typeson-registry/node_modules/.pnpm/[email protected][email protected]/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js:35:11)
    at HTMLCanvasElement.getContext (/Users/brett/typeson-registry/node_modules/.pnpm/[email protected][email protected]/node_modules/jsdom/lib/jsdom/living/generated/HTMLCanvasElement.js:131:58)
    at file:///Users/brett/typeson-registry/.idea/canvas.js:6:20
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:106:12)

Node.js v18.20.3

Your Environment

  • Version of node-canvas (output of npm list canvas or yarn list canvas): 3.0.0-rc2
  • Environment (e.g. node 20.9.0 on macOS 14.1.1): v18.16.0 on macOS 14.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions