Skip to content

Commit 1a0dd50

Browse files
committed
Ensure canvas exists when initializing Chart.js
When initializing the chart, the import for chart.js is dynamic which means its possible for the canvas to be removed before we call chart.js's initialization function. This can cause sporadic failures during tests if components are being loaded for short periods of times. During general use it's unlikely to happen as the import is likely to be resolved quickly.
1 parent afe6f58 commit 1a0dd50

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/primevue/src/chart/Chart.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default {
4848
this.chart = null;
4949
}
5050
51-
if (module && module.default) {
51+
if (module && module.default && this.$refs.canvas) {
5252
this.chart = new module.default(this.$refs.canvas, {
5353
type: this.type,
5454
data: this.data,

0 commit comments

Comments
 (0)