From e1fa845293c5056d36958fcec6244c049f1a7c02 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 25 Jul 2021 13:18:24 +0200 Subject: [PATCH] Only define *existing* methods, when converting the `OPS` format to method-names on the `CanvasGraphics.prototype` There's no good reason, as far as I can tell, to explicitly define a bunch of methods to be `undefined`, which the current unconditional "copying" of methods will do. Note that of the `OPS` ~23 percent don't, for various reasons, have an associated method on the `CanvasGraphics.prototype`. --- src/display/canvas.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/display/canvas.js b/src/display/canvas.js index e8aae4215..1cf328966 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -2804,7 +2804,9 @@ class CanvasGraphics { } for (const op in OPS) { - CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op]; + if (CanvasGraphics.prototype[op] !== undefined) { + CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op]; + } } export { CanvasGraphics };