File tree 2 files changed +41
-1
lines changed
2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -670,5 +670,42 @@ describe('error handling', () => {
670
670
)
671
671
} )
672
672
673
+ // #11624
674
+ test ( 'in computed that is used as key for watch' , async ( ) => {
675
+ const err = new Error ( 'foo' )
676
+ const fn = vi . fn ( )
677
+ const trigger = ref ( false )
678
+
679
+ const Comp = {
680
+ setup ( ) {
681
+ onErrorCaptured ( ( err , instance , info ) => {
682
+ fn ( err , info )
683
+ return false
684
+ } )
685
+ return ( ) => h ( Child )
686
+ } ,
687
+ }
688
+
689
+ const Child = {
690
+ setup ( ) {
691
+ const foo = computed ( ( ) => {
692
+ if ( trigger . value ) throw err
693
+ return 1
694
+ } )
695
+ watch ( foo , ( ) => { } )
696
+ return ( ) => null
697
+ } ,
698
+ }
699
+
700
+ render ( h ( Comp ) , nodeOps . createElement ( 'div' ) )
701
+
702
+ trigger . value = true
703
+ await nextTick ( )
704
+ expect ( fn ) . toHaveBeenCalledWith (
705
+ err ,
706
+ ErrorTypeStrings [ ErrorCodes . COMPONENT_UPDATE ] ,
707
+ )
708
+ } )
709
+
673
710
// native event handler handling should be tested in respective renderers
674
711
} )
Original file line number Diff line number Diff line change @@ -400,7 +400,10 @@ function doWatch(
400
400
} else {
401
401
// default: 'pre'
402
402
job . flags ! |= SchedulerJobFlags . PRE
403
- if ( instance ) job . id = instance . uid
403
+ if ( instance ) {
404
+ job . id = instance . uid
405
+ job . i = instance
406
+ }
404
407
scheduler = ( ) => queueJob ( job )
405
408
}
406
409
effect . scheduler = scheduler
You can’t perform that action at this time.
0 commit comments