Skip to content

Commit

Permalink
chore(Canvas): do not query DOM for markers
Browse files Browse the repository at this point in the history
  • Loading branch information
marstamm committed Jun 27, 2024
1 parent 2c0e567 commit 6cefa79
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/core/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ Canvas.prototype._updateMarker = function(element, marker, add) {
element = this._elementRegistry.get(element);
}

element.markers = element.markers || new Set();

// we need to access all
container = this._elementRegistry._elements[element.id];

Expand All @@ -573,8 +575,10 @@ Canvas.prototype._updateMarker = function(element, marker, add) {

// invoke either addClass or removeClass based on mode
if (add) {
element.markers.add(marker);
svgClasses(gfx).add(marker);
} else {
element.markers.delete(marker);
svgClasses(gfx).remove(marker);
}
}
Expand Down Expand Up @@ -642,9 +646,11 @@ Canvas.prototype.hasMarker = function(element, marker) {
element = this._elementRegistry.get(element);
}

const gfx = this.getGraphics(element);
if (!element.markers) {
return false;
}

return svgClasses(gfx).has(marker);
return element.markers.has(marker);
};

/**
Expand Down

0 comments on commit 6cefa79

Please sign in to comment.