From c20426efef220e5ec594e11af13a5a004246901b Mon Sep 17 00:00:00 2001 From: swftvsn Date: Tue, 20 Mar 2018 11:16:07 +0200 Subject: [PATCH] Improve node.js support This change fixes "Unhandled rejection ReferenceError: HTMLElement is not defined" issue that is discussed in more detail in #8489. --- src/display/canvas.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/display/canvas.js b/src/display/canvas.js index 9a75ac3a7..485bad41d 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -2112,8 +2112,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { var heightScale = Math.max(Math.sqrt(c * c + d * d), 1); var imgToPaint, tmpCanvas; - // instanceof HTMLElement does not work in jsdom node.js module - if (imgData instanceof HTMLElement || !imgData.data) { + // typeof check is needed due to node.js support, see issue #8489 + if ((typeof HTMLElement === 'function' && + imgData instanceof HTMLElement) || !imgData.data) { imgToPaint = imgData; } else { tmpCanvas = this.cachedCanvases.getCanvas('inlineImage',