File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
test/unit/features/options Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
3
import { hasSymbol } from 'core/util/env'
4
+ import { defineReactive } from '../observer/index'
4
5
5
6
export function initProvide ( vm : Component ) {
6
7
const provide = vm . $options . provide
@@ -29,7 +30,7 @@ export function initInjections (vm: Component) {
29
30
let source = vm
30
31
while ( source ) {
31
32
if ( source . _provided && provideKey in source . _provided ) {
32
- vm [ key ] = source . _provided [ provideKey ]
33
+ defineReactive ( vm , key , source . _provided [ provideKey ] )
33
34
break
34
35
}
35
36
source = source . $parent
Original file line number Diff line number Diff line change @@ -162,4 +162,38 @@ describe('Options provide/inject', () => {
162
162
expect ( vm . $el . textContent ) . toBe ( '123' )
163
163
} )
164
164
}
165
+
166
+ // Github issue #5223
167
+ it ( 'should work with reactive array' , done => {
168
+ const vm = new Vue ( {
169
+ template : `<div><child></child></div>` ,
170
+ data ( ) {
171
+ return {
172
+ foo : [ ]
173
+ }
174
+ } ,
175
+ provide ( ) {
176
+ return {
177
+ foo : this . foo
178
+ }
179
+ } ,
180
+ components : {
181
+ child : {
182
+ inject : [ 'foo' ] ,
183
+ template : `<span>{{foo.length}}</span>`
184
+ }
185
+ }
186
+ } ) . $mount ( )
187
+
188
+ expect ( vm . $el . innerHTML ) . toEqual ( `<span>0</span>` )
189
+ vm . foo . push ( vm . foo . length )
190
+ vm . $nextTick ( ( ) => {
191
+ expect ( vm . $el . innerHTML ) . toEqual ( `<span>1</span>` )
192
+ vm . foo . pop ( )
193
+ vm . $nextTick ( ( ) => {
194
+ expect ( vm . $el . innerHTML ) . toEqual ( `<span>0</span>` )
195
+ done ( )
196
+ } )
197
+ } )
198
+ } )
165
199
} )
You can’t perform that action at this time.
0 commit comments