Improve node.js support

This change fixes "Unhandled rejection ReferenceError: HTMLElement is not defined" issue that is discussed in more detail in #8489.
This commit is contained in:
swftvsn 2018-03-20 11:16:07 +02:00 committed by lemontree10
parent 3bfc797bc7
commit c20426efef

View File

@ -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',