From 5137a42e8ec83ade2dbaeceb2450b98c621180a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Davidovi=C4=87?= Date: Fri, 2 Jun 2023 14:21:10 +0200 Subject: [PATCH 1/2] Don't re-add existing styles to SVGShapeElement When calling `SVGShapeElement.reloadShapes()`, `searchShapes()` will correctly reconciliate modified and added shapes and reuse their elements. However, it will call `setElementStyles()`, which will add all styles unconditionally to `this.stylesList`, even if the styles were already in there. Modify `setElementStyles()` to check for the existence of a particular style before adding it. --- player/js/elements/svgElements/SVGShapeElement.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/player/js/elements/svgElements/SVGShapeElement.js b/player/js/elements/svgElements/SVGShapeElement.js index d71d17c43..7cd9d83af 100644 --- a/player/js/elements/svgElements/SVGShapeElement.js +++ b/player/js/elements/svgElements/SVGShapeElement.js @@ -211,6 +211,10 @@ SVGShapeElement.prototype.setElementStyles = function (elementData) { var j; var jLen = this.stylesList.length; for (j = 0; j < jLen; j += 1) { + if (arr.indexOf(this.stylesList[j]) !== -1) { + continue; + } + if (!this.stylesList[j].closed) { arr.push(this.stylesList[j]); } From 7b75a9950b7adc22f2e2f558f993eadb3ea777f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Davidovi=C4=87?= Date: Fri, 9 Jun 2023 02:09:03 +0200 Subject: [PATCH 2/2] Fix ESLint error --- player/js/elements/svgElements/SVGShapeElement.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/player/js/elements/svgElements/SVGShapeElement.js b/player/js/elements/svgElements/SVGShapeElement.js index 7cd9d83af..a04c20a34 100644 --- a/player/js/elements/svgElements/SVGShapeElement.js +++ b/player/js/elements/svgElements/SVGShapeElement.js @@ -211,11 +211,7 @@ SVGShapeElement.prototype.setElementStyles = function (elementData) { var j; var jLen = this.stylesList.length; for (j = 0; j < jLen; j += 1) { - if (arr.indexOf(this.stylesList[j]) !== -1) { - continue; - } - - if (!this.stylesList[j].closed) { + if (arr.indexOf(this.stylesList[j]) === -1 && !this.stylesList[j].closed) { arr.push(this.stylesList[j]); } }