File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,21 @@ export default class SwupLivewirePlugin extends Plugin {
4343 el . setAttribute ( 'wire:initial-data' , JSON . stringify ( data ) ) ;
4444 } ) ;
4545
46- // Aleays restart Livewire
47- window . Livewire . restart ( ) ;
46+ // Always restart Livewire
47+ if ( typeof window . Livewire . restart === 'function' ) {
48+ window . Livewire . restart ( ) ;
49+ } else {
50+ // handle versions of Livewire that don't have the .restart() method
51+ window . Livewire . all ( ) . map ( ( component ) => {
52+ // not always defined - depends on the component
53+ if ( typeof component . call === 'function' ) {
54+ return component . call ( 'restart' ) ;
55+ }
56+ // alternative version to component.call('restart') in case that doesn't exist
57+ if ( typeof component . $wire ?. $refresh === 'function' ) {
58+ component . $wire . $refresh ( ) ;
59+ }
60+ } ) ;
61+ }
4862 }
4963}
You can’t perform that action at this time.
0 commit comments