File tree 2 files changed +50
-1
lines changed
2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,12 @@ export function asVmProperty(
47
47
} ,
48
48
} )
49
49
} else {
50
- vm . _data [ propName ] = propValue
50
+ proxy ( vm . _data , propName , {
51
+ get : ( ) => propValue ,
52
+ set : ( val : any ) => {
53
+ propValue = val
54
+ } ,
55
+ } )
51
56
}
52
57
} )
53
58
}
Original file line number Diff line number Diff line change @@ -898,6 +898,50 @@ describe('setup', () => {
898
898
expect ( vm . $el . textContent ) . toBe ( '2' )
899
899
} )
900
900
901
+ // #679
902
+ it ( 'should work merge with object in development' , async ( ) => {
903
+ global . __DEV__ = true
904
+ const vm = new Vue ( {
905
+ template : '<div>{{ data.id }}</div>' ,
906
+ setup ( ) {
907
+ const data = reactive ( {
908
+ id : 42 ,
909
+ } )
910
+ return { data }
911
+ } ,
912
+ data ( ) {
913
+ return {
914
+ data : { id : 1 } ,
915
+ }
916
+ } ,
917
+ } ) . $mount ( )
918
+
919
+ await nextTick ( )
920
+ expect ( vm . $el . textContent ) . toBe ( '1' )
921
+ } )
922
+
923
+ // #679
924
+ it ( 'should work merge with object in production' , async ( ) => {
925
+ global . __DEV__ = false
926
+ const vm = new Vue ( {
927
+ template : '<div>{{ data.id }}</div>' ,
928
+ setup ( ) {
929
+ const data = reactive ( {
930
+ id : 42 ,
931
+ } )
932
+ return { data }
933
+ } ,
934
+ data ( ) {
935
+ return {
936
+ data : { id : 1 } ,
937
+ }
938
+ } ,
939
+ } ) . $mount ( )
940
+
941
+ await nextTick ( )
942
+ expect ( vm . $el . textContent ) . toBe ( '1' )
943
+ } )
944
+
901
945
// #683 #603 #580
902
946
it ( 'should update directly when adding attributes to a reactive object' , async ( ) => {
903
947
const vm = new Vue ( {
You can’t perform that action at this time.
0 commit comments