Skip to content

Commit 9be7b0b

Browse files
author
Lionel Laské
committed
Merge branch 'pr/1894' into dev
2 parents cc919ce + 954ad2b commit 9be7b0b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

js/components/icon.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const Icon ={
5656
disabledData: this.disabled ? this.disabled: false,
5757
_originalColor: { fill: null, stroke: null},
5858
_element: null,
59+
_errorHandler: null,
5960
fallback: false
6061
}
6162
},
@@ -78,6 +79,20 @@ const Icon ={
7879
})();
7980
}
8081
},
82+
unmounted() {
83+
// Clean up event listeners
84+
if (this._element && this._errorHandler) {
85+
const useElement = this._element.querySelector('use');
86+
if (useElement) {
87+
useElement.removeEventListener('error', this._errorHandler);
88+
}
89+
}
90+
// Clear DOM references
91+
this._element = null;
92+
this._svg = null;
93+
this._originalColor = null;
94+
this._errorHandler = null;
95+
},
8196
computed: {
8297
gensvg: function() {
8398
if (this._svg == null) return "";
@@ -221,9 +236,10 @@ const Icon ={
221236
}
222237

223238
var useElement = document.createElementNS(svgElement.namespaceURI,"use");
224-
useElement.addEventListener('error', function() {
239+
this._errorHandler = function() {
225240
console.log(svgfile+' error');
226-
}) // Error loading SVG file
241+
};
242+
useElement.addEventListener('error', this._errorHandler); // Error loading SVG file
227243

228244
var xref = svgfile+"#icon";
229245
useElement.setAttribute("xlink:href",xref);

0 commit comments

Comments
 (0)