I have a custom element that extends a canvas. But when I add the custom element to the dom, the width is undefined. Here is my code.
class Renderer extends HTMLCanvasElement {
constructor() {
super();
}
}
customElements.define("render-area", Renderer, { extends: 'canvas' });
<render-area width="500" height="500" style="border: 3px solid black"></render-area>
<button onclick = "console.log(document.querySelector('render-area').width)">log width of render area</button>
What am I doing wrong here?