File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,11 @@ export function mixin(Vue: VueConstructor) {
124
124
if ( ! isRef ( bindingValue ) ) {
125
125
if ( ! isReactive ( bindingValue ) ) {
126
126
if ( isFunction ( bindingValue ) ) {
127
+ const copy = bindingValue
127
128
bindingValue = bindingValue . bind ( vm )
129
+ Object . keys ( copy ) . forEach ( function ( ele ) {
130
+ bindingValue [ ele ] = copy [ ele ]
131
+ } )
128
132
} else if ( ! isObject ( bindingValue ) ) {
129
133
bindingValue = ref ( bindingValue )
130
134
} else if ( hasReactiveArrayChild ( bindingValue ) ) {
Original file line number Diff line number Diff line change @@ -1193,4 +1193,30 @@ describe('setup', () => {
1193
1193
const vm = new Vue ( Constructor ) . $mount ( )
1194
1194
expect ( vm . proxy ) . toBe ( originalProxy )
1195
1195
} )
1196
+
1197
+ // test #687
1198
+ it ( 'properties of function should not disappear' , ( ) => {
1199
+ Vue . component ( 'todo' , {
1200
+ template : '<div/>' ,
1201
+ props : [ 'testFn' ] ,
1202
+ setup ( props ) {
1203
+ expect ( props . testFn . a ) . toBe ( 2 )
1204
+ } ,
1205
+ } )
1206
+
1207
+ const vm = new Vue ( {
1208
+ template : `
1209
+ <div>
1210
+ <todo :testFn="testFn"></todo>
1211
+ </div>
1212
+ ` ,
1213
+ setup ( ) {
1214
+ const testFn = ( ) => {
1215
+ console . log ( 1 )
1216
+ }
1217
+ testFn . a = 2
1218
+ return { testFn }
1219
+ } ,
1220
+ } ) . $mount ( )
1221
+ } )
1196
1222
} )
You can’t perform that action at this time.
0 commit comments