* @param {EachState} state * @param {Effect[]} to_destroy * @param {boolean} remove_dom
(state, to_destroy, remove_dom = true)
| 133 | * @param {boolean} remove_dom |
| 134 | */ |
| 135 | function destroy_effects(state, to_destroy, remove_dom = true) { |
| 136 | /** @type {Set<Effect> | undefined} */ |
| 137 | var preserved_effects; |
| 138 | |
| 139 | // The loop-in-a-loop isn't ideal, but we should only hit this in relatively rare cases |
| 140 | if (state.pending.size > 0) { |
| 141 | preserved_effects = new Set(); |
| 142 | |
| 143 | for (const keys of state.pending.values()) { |
| 144 | for (const key of keys) { |
| 145 | preserved_effects.add(/** @type {EachItem} */ (state.items.get(key)).e); |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | for (var i = 0; i < to_destroy.length; i++) { |
| 151 | var e = to_destroy[i]; |
| 152 | |
| 153 | if (preserved_effects?.has(e)) { |
| 154 | e.f |= EFFECT_OFFSCREEN; |
| 155 | |
| 156 | const fragment = document.createDocumentFragment(); |
| 157 | move_effect(e, fragment); |
| 158 | } else { |
| 159 | destroy_effect(to_destroy[i], remove_dom); |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | /** @type {TemplateNode} */ |
| 165 | var offscreen_anchor; |
no test coverage detected