Skip to content

Commit a0ae8a1

Browse files
authored
Fix the usage where jsDOM is not present (#688)
* Fix the usage where jsDOM is not present * apply review * apply review 2
1 parent b6f61ad commit a0ae8a1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/helpers/helpers.canvas.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ import {calculateTextAlignment, getSize} from './helpers.options';
44

55
const widthCache = new Map();
66

7+
/**
8+
* Determine if content is an image or a canvas.
9+
* @param {*} content
10+
* @returns boolean|undefined
11+
* @todo move this function to chart.js helpers
12+
*/
713
export function isImageOrCanvas(content) {
8-
return content instanceof Image || content instanceof HTMLCanvasElement;
14+
if (content && typeof content === 'object') {
15+
const type = content.toString();
16+
return (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]');
17+
}
918
}
1019

1120
/**

0 commit comments

Comments
 (0)