@@ -34,8 +34,17 @@ export function morph(from, toHtml, options) {
34
34
}
35
35
36
36
let updateChildrenOnly = false
37
-
38
- if ( shouldSkip ( updating , from , to , ( ) => updateChildrenOnly = true ) ) return
37
+ let skipChildren = false
38
+
39
+ // If we used `shouldSkip()` here and append the `skipChildren` function on the end, it will cause the signature of the `updating`
40
+ // hook to change. For example, when it was `shouldSkip()` the signature was `updating: (el, toEl, childrenOnly, skip)`. But if
41
+ // we append `skipChildren()`, it would make the signature `updating: (el, toEl, childrenOnly, skipChildren, skip)`. This is
42
+ // a breaking change due to how the `shouldSkip()` function is structured.
43
+ //
44
+ // So we're using `shouldSkipChildren()` instead which doesn't have this problem as it allows us to pass in the `skipChildren()`
45
+ // function as an earlier parameter and then append it to the `updating` hook signature manually. The signature of `updating`
46
+ // hook is now `updating: (el, toEl, childrenOnly, skip, skipChildren)`.
47
+ if ( shouldSkipChildren ( updating , ( ) => skipChildren = true , from , to , ( ) => updateChildrenOnly = true ) ) return
39
48
40
49
// Initialize the server-side HTML element with Alpine...
41
50
if ( from . nodeType === 1 && window . Alpine ) {
@@ -60,7 +69,9 @@ export function morph(from, toHtml, options) {
60
69
61
70
updated ( from , to )
62
71
63
- patchChildren ( from , to )
72
+ if ( ! skipChildren ) {
73
+ patchChildren ( from , to )
74
+ }
64
75
}
65
76
66
77
function differentElementNamesTypesOrKeys ( from , to ) {
@@ -386,6 +397,19 @@ function shouldSkip(hook, ...args) {
386
397
return skip
387
398
}
388
399
400
+ // Due to the structure of the `shouldSkip()` function, we can't pass in the `skipChildren`
401
+ // function as an argument as it would change the signature of the existing hooks. So we
402
+ // are using this function instead which doesn't have this problem as we can pass the
403
+ // `skipChildren` function in as an earlier argument and then append it to the end
404
+ // of the hook signature manually.
405
+ function shouldSkipChildren ( hook , skipChildren , ...args ) {
406
+ let skip = false
407
+
408
+ hook ( ...args , ( ) => skip = true , skipChildren )
409
+
410
+ return skip
411
+ }
412
+
389
413
let patched = false
390
414
391
415
export function createElement ( html ) {
0 commit comments