mercredi 31 mars 2021

Is there a way to extend SVGElement like HTMLElement

I'm making a small JS library. I was creating custom elements using the HTMLElement interface. Now I want to make a custom graphing tool and for that, I want my element to extend SVGElement.

I have a class Graph.js which extends SVGElement and a main.js which instantiates a graph.

This is my class Graph.js :


export class Graph extends SVGElement {

    constructor() {
        super();

    }

}

and Main.js:

import { Graph } from './Experimental/Graph/Graph.js';

customElements.define('pro-graph', Graph);

let graph = new Graph();


But for some reason I get this error:

Uncaught TypeError: Illegal constructor.
    <anonymous> debugger eval code:1



Aucun commentaire:

Enregistrer un commentaire