@@ -36,7 +36,15 @@ export function morph(from, toHtml, options) {
3636 let updateChildrenOnly = false
3737 let skipChildren = false
3838
39- if ( shouldSkip ( updating , from , to , ( ) => updateChildrenOnly = true , ( ) => skipChildren = true ) ) return
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
4048
4149 // Initialize the server-side HTML element with Alpine...
4250 if ( from . nodeType === 1 && window . Alpine ) {
@@ -389,6 +397,19 @@ function shouldSkip(hook, ...args) {
389397 return skip
390398}
391399
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+
392413let patched = false
393414
394415export function createElement ( html ) {
0 commit comments