zenozeng/p5.js-svg

Relocating the canvas results in an error

bcorporaal opened this issue · 2 comments

Issue
Relocating the created using p5.Element.parent() results in the following error:
Uncaught (in promise) TypeError: Node.appendChild: Argument 1 does not implement interface Node.

Code

function setup() {
    let p5Canvas = createCanvas(400, 400, SVG);
    p5Canvas.parent("sketch-canvas");
}

Without SVG the code works fine:

function setup() {
    let p5Canvas = createCanvas(400, 400);
    p5Canvas.parent("sketch-canvas");
}

To follow-up, this code also works without issue:

function setup() {
    createCanvas(400, 400, SVG);
    let destination = document.getElementById("sketch-canvas");
    let p5Canvas = document.getElementById("defaultCanvas0");

    destination.appendChild(p5Canvas);
}

@bcorporaal Thank you for reporting the bug. It is fixed in v1.0.8.