Skip to content

Commit

Permalink
Improve node.js support
Browse files Browse the repository at this point in the history
This change fixes "Unhandled rejection ReferenceError: HTMLElement is not defined" issue that is discussed in more detail in mozilla#8489.
  • Loading branch information
swftvsn authored and lemontree10 committed Mar 21, 2018
1 parent 3bfc797 commit c20426e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit c20426e

Please sign in to comment.