diff --git a/packages/html/src/index.ts b/packages/html/src/index.ts
index 86b9b56..ddd22e1 100644
--- a/packages/html/src/index.ts
+++ b/packages/html/src/index.ts
@@ -176,10 +176,8 @@ function spawnUIFragmentFactory(thisFacet: Facet) {
let insertionPoint = findInsertionPoint(anchorNode, orderBy, fragmentId);
while (true) {
let n = insertionPoint ? insertionPoint.previousSibling : anchorNode.lastChild;
- if (n && hasSortKey(n, orderBy, fragmentId)) {
- // auto-updates previousSibling/lastChild
- n.parentNode?.removeChild(n);
- }
+ if (!(n && hasSortKey(n, orderBy, fragmentId))) break;
+ n.parentNode?.removeChild(n); // auto-updates previousSibling/lastChild
}
});
}
@@ -206,8 +204,7 @@ function spawnUIFragmentFactory(thisFacet: Facet) {
let insertionPoint = findInsertionPoint(anchorNode, orderBy, fragmentId);
while (true) {
let uiNode = insertionPoint ? insertionPoint.previousSibling : anchorNode.lastChild;
- if (uiNode === null) break;
- if (!hasSortKey(uiNode, orderBy, fragmentId)) break;
+ if (!(uiNode && hasSortKey(uiNode, orderBy, fragmentId))) break;
if (isQueryableNode(uiNode)) {
selectorMatch(uiNode, selector).forEach(
eventUpdater(cleanEventType(eventType), handlerClosure, install));