Prevent references to nodes swapped out of the dom accumulating as detached elements in memory (#2091)

* Prevent references to elements swapped out of the dom accumulating as detached nodes (memory leak).

* Safely delete internal data when we tear down a node
This commit is contained in:
Mark Croxton 2023-12-14 19:12:34 +00:00 committed by GitHub
parent 4057f9c465
commit 9052a4d520
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -961,10 +961,8 @@ return (function () {
}
});
}
if (internalData.initHash) {
internalData.initHash = null
}
deInitOnHandlers(element);
forEach(Object.keys(internalData), function(key) { delete internalData[key] });
}
function cleanUpElement(element) {
@ -988,7 +986,6 @@ return (function () {
} else {
newElt = eltBeforeNewContent.nextSibling;
}
getInternalData(target).replacedWith = newElt; // tuck away so we can fire events on it later
settleInfo.elts = settleInfo.elts.filter(function(e) { return e != target });
while(newElt && newElt !== target) {
if (newElt.nodeType === Node.ELEMENT_NODE) {