Skip to content

Commit

Permalink
addListener and removeListener are only invoked on defined (and valid…
Browse files Browse the repository at this point in the history
…) values (#11685)
  • Loading branch information
DAcodedBEAT authored Feb 28, 2024
1 parent 4068bd8 commit bbdaa6a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/platform/platform.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ function initCanvas(canvas, aspectRatio) {
const eventListenerOptions = supportsEventListenerOptions ? {passive: true} : false;

function addListener(node, type, listener) {
node.addEventListener(type, listener, eventListenerOptions);
if (node) {
node.addEventListener(type, listener, eventListenerOptions);
}
}

function removeListener(chart, type, listener) {
chart.canvas.removeEventListener(type, listener, eventListenerOptions);
if (chart && chart.canvas) {
chart.canvas.removeEventListener(type, listener, eventListenerOptions);
}
}

function fromNativeEvent(event, chart) {
Expand Down

0 comments on commit bbdaa6a

Please sign in to comment.