@@ -96,7 +96,10 @@ function createMorphContext(options = {}) {
96
96
// So we're using `shouldSkipChildren()` instead which doesn't have this problem as it allows us to pass in the `skipChildren()`
97
97
// function as an earlier parameter and then append it to the `updating` hook signature manually. The signature of `updating`
98
98
// hook is now `updating: (el, toEl, childrenOnly, skip, skipChildren)`.
99
- if ( shouldSkipChildren ( context . updating , ( ) => skipChildren = true , from , to , ( ) => updateChildrenOnly = true ) ) return
99
+
100
+ let skipUntil = predicate => context . skipUntilCondition = predicate
101
+
102
+ if ( shouldSkipChildren ( context . updating , ( ) => skipChildren = true , skipUntil , from , to , ( ) => updateChildrenOnly = true ) ) return
100
103
101
104
// Initialize the server-side HTML element with Alpine...
102
105
if ( from . nodeType === 1 && window . Alpine ) {
@@ -201,6 +204,18 @@ function createMorphContext(options = {}) {
201
204
let toKey = context . getKey ( currentTo )
202
205
let fromKey = context . getKey ( currentFrom )
203
206
207
+ if ( context . skipUntilCondition ) {
208
+ let fromDone = ! currentFrom || context . skipUntilCondition ( currentFrom )
209
+ let toDone = ! currentTo || context . skipUntilCondition ( currentTo )
210
+ if ( fromDone && toDone ) {
211
+ context . skipUntilCondition = null
212
+ } else {
213
+ if ( ! fromDone ) currentFrom = currentFrom && getNextSibling ( from , currentFrom )
214
+ if ( ! toDone ) currentTo = currentTo && getNextSibling ( to , currentTo )
215
+ continue
216
+ }
217
+ }
218
+
204
219
// Add new elements...
205
220
if ( ! currentFrom ) {
206
221
if ( toKey && fromKeyHoldovers [ toKey ] ) {
@@ -431,11 +446,9 @@ function shouldSkip(hook, ...args) {
431
446
// are using this function instead which doesn't have this problem as we can pass the
432
447
// `skipChildren` function in as an earlier argument and then append it to the end
433
448
// of the hook signature manually.
434
- function shouldSkipChildren ( hook , skipChildren , ...args ) {
449
+ function shouldSkipChildren ( hook , skipChildren , skipUntil , ...args ) {
435
450
let skip = false
436
-
437
- hook ( ...args , ( ) => skip = true , skipChildren )
438
-
451
+ hook ( ...args , ( ) => skip = true , skipChildren , skipUntil )
439
452
return skip
440
453
}
441
454
0 commit comments