File tree 2 files changed +33
-5
lines changed
test/unit/features/options
2 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -85,18 +85,18 @@ export function mergeDataOrFn (
85
85
// it has to be a function to pass previous merges.
86
86
return function mergedDataFn ( ) {
87
87
return mergeData (
88
- typeof childVal === 'function' ? childVal . call ( this ) : childVal ,
89
- typeof parentVal === 'function' ? parentVal . call ( this ) : parentVal
88
+ typeof childVal === 'function' ? childVal . call ( this , this ) : childVal ,
89
+ typeof parentVal === 'function' ? parentVal . call ( this , this ) : parentVal
90
90
)
91
91
}
92
92
} else {
93
93
return function mergedInstanceDataFn ( ) {
94
94
// instance merge
95
95
const instanceData = typeof childVal === 'function'
96
- ? childVal . call ( vm )
96
+ ? childVal . call ( vm , vm )
97
97
: childVal
98
98
const defaultData = typeof parentVal === 'function'
99
- ? parentVal . call ( vm )
99
+ ? parentVal . call ( vm , vm )
100
100
: parentVal
101
101
if ( instanceData ) {
102
102
return mergeData ( instanceData , defaultData )
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ describe('Options data', () => {
107
107
expect ( vm . a ) . toBe ( 1 )
108
108
} )
109
109
110
- it ( 'should called with this' , ( ) => {
110
+ it ( 'should be called with this' , ( ) => {
111
111
const vm = new Vue ( {
112
112
template : '<div><child></child></div>' ,
113
113
provide : { foo : 1 } ,
@@ -123,4 +123,32 @@ describe('Options data', () => {
123
123
} ) . $mount ( )
124
124
expect ( vm . $el . innerHTML ) . toBe ( '<span>foo:1</span>' )
125
125
} )
126
+
127
+ it ( 'should be called with vm as first argument when merged' , ( ) => {
128
+ const superComponent = {
129
+ data : ( { foo } ) => ( { ext : 'ext:' + foo } )
130
+ }
131
+ const mixins = [
132
+ {
133
+ data : ( { foo } ) => ( { mixin1 : 'm1:' + foo } )
134
+ } ,
135
+ {
136
+ data : ( { foo } ) => ( { mixin2 : 'm2:' + foo } )
137
+ }
138
+ ]
139
+ const vm = new Vue ( {
140
+ template : '<div><child></child></div>' ,
141
+ provide : { foo : 1 } ,
142
+ components : {
143
+ child : {
144
+ extends : superComponent ,
145
+ mixins,
146
+ template : '<span>{{bar}}-{{ext}}-{{mixin1}}-{{mixin2}}</span>' ,
147
+ inject : [ 'foo' ] ,
148
+ data : ( { foo } ) => ( { bar : 'foo:' + foo } )
149
+ }
150
+ }
151
+ } ) . $mount ( )
152
+ expect ( vm . $el . innerHTML ) . toBe ( '<span>foo:1-ext:1-m1:1-m2:1</span>' )
153
+ } )
126
154
} )
You can’t perform that action at this time.
0 commit comments