0

I use a framework that converts variables to Proxies. The proxy contains an ImageBitmap that I want to draw, but drawImage throws an error like "you can't use the Proxy here". How do I fix it?

var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
img = new Image();
var handler = { // idk which handler used 
    get: function(target, name){
        return name in target?
            target[name] :
            37; 
    }
};
var image = new Proxy(img, handler); // in the project it already set

ctx.drawImage(image /* error  */, image.height, image.widht);
<canvas id="canvas">
hheimerd
  • 33
  • 3
  • Imagine that the proxy is not an Image, but an ImageBitmap – hheimerd Mar 31 '21 at 07:18
  • Possible duplicate: [Is it possible to use Proxy with native browser objects (HTMLElement, Canvas2DRenderingContext ,…)?](https://stackoverflow.com/questions/48535551/is-it-possible-to-use-proxy-with-native-browser-objects-htmlelement-canvas2dre) – Andreas Mar 31 '21 at 07:22
  • I can't change handler and I want to use Proxy target, but not Proxy function – hheimerd Mar 31 '21 at 09:54

0 Answers0