Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.15k stars 1.17k forks source link

Object.getOwnPropertyDescriptor(CanvasRenderingContext2D.prototype, "strokeStyle"); #1460

Open dreamsky124 opened 5 years ago

dreamsky124 commented 5 years ago

Object.getOwnPropertyDescriptor(CanvasRenderingContext2D.prototype, "strokeStyle");

"TypeError: Method strokeStyle called on incompatible receiver [object Object]

others no problem eg: Object.getOwnPropertyDescriptor(CanvasRenderingContext2D.prototype, "fillText");

Environment

node-cavas:2.5.0 node:V10.16.0 windows7 64bit

zbjornson commented 5 years ago

fillText is a method, strokeStyle is a getter/setter. You'll see the same TypeError for all getters/setters.

This is intentional since https://github.com/Automattic/node-canvas/pull/808. Neither Chrome nor Firefox have this behavior (they return the descriptor), but I'm not sure we can do the same from a native module.

BridgeAR commented 2 years ago

@zbjornson I would expect the getter/setter to be returned along a descriptor. Is it possible to change that somehow? Currently V8 is not able to handle this: https://github.com/nodejs/node/issues/39866#issuecomment-907257552

zbjornson commented 2 years ago

@BridgeAR if there is, I don't know how. Do you know who we could ask who's more deeply familiar with the V8 API?