Here you are missing some points, when expanding your own object, you should use the option extends:
canvasConstructor = document.registerElement("custom-canvas", { prototype: customCanvas, extends: 'canvas' });
And you cannot create directly custom type extensions, therefore you cannot do it createElement("custom-canvas"), you must use the attribute is, and for this you must use createElementwith two parameters:
canvas = document.createElement('canvas', 'custom-canvas');
//canvas in HTML will be <canvas is="custom-canvas"></canvas>
//<custom-canvas></custom-canvas> is invalid
By doing all this, you can use an extension like:
ctx = canvas.getContext('2d'); //no error :)
source
share