From 1d8b4ace49918af3b1816d63f03ea2c7894dbd19 Mon Sep 17 00:00:00 2001 From: MichaelWest22 Date: Fri, 20 Dec 2024 16:41:31 +1300 Subject: [PATCH] replace set intersection with function as it is not in all browsers yet. --- src/idiomorph.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/idiomorph.js b/src/idiomorph.js index 2870e4d..945ecfc 100644 --- a/src/idiomorph.js +++ b/src/idiomorph.js @@ -1100,8 +1100,7 @@ var Idiomorph = (function () { // places where tempNode may be just a Node, not an Element function removeNode(tempNode, ctx) { removeIdsFromConsideration(ctx, tempNode) - // @ts-ignore - use new set intersection feature - if (ctx.pantry && ctx.idMap.get(tempNode)?.intersection(ctx.persistentIds).size > 0 && tempNode instanceof Element) { + if (ctx.pantry && hasPersistentIdNodes(ctx, tempNode) && tempNode instanceof Element) { moveToPantry(tempNode, ctx); } else { if (ctx.callbacks.beforeNodeRemoved(tempNode) === false) return; @@ -1226,6 +1225,21 @@ var Idiomorph = (function () { } } + /** + * + * @param {MorphContext} ctx + * @param {Node} node + * @returns {boolean} + */ + function hasPersistentIdNodes(ctx, node) { + for (const id of ctx.idMap.get(node) || EMPTY_SET) { + if (ctx.persistentIds.has(id)) { + return true; + } + } + return false; + } + /** * * @param {MorphContext} ctx