Skip to content

Commit 00d11a9

Browse files
committed
Fixed bug when calling defineReactive on non-existent field with convertAllProperties on
1 parent 01825aa commit 00d11a9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/observer/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ function defineReactive (obj, key, val) {
181181
if (property && property.configurable === false) {
182182
return
183183
}
184-
getter = property.get
185-
setter = property.set
184+
getter = property && property.get
185+
setter = property && property.set
186186
}
187187

188188
var childOb = Observer.create(val)

test/unit/specs/directives/public/for/for_spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var _ = require('../../../../../../src/util')
22
var Vue = require('../../../../../../src/vue')
3+
var config = require('../../../../../../src/config')
34

45
if (_.inBrowser) {
56
describe('v-for', function () {
@@ -8,6 +9,7 @@ if (_.inBrowser) {
89
beforeEach(function () {
910
el = document.createElement('div')
1011
spyOn(_, 'warn')
12+
config.convertAllProperties = false
1113
})
1214

1315
it('objects', function (done) {
@@ -21,6 +23,18 @@ if (_.inBrowser) {
2123
assertMutations(vm, el, done)
2224
})
2325

26+
it('objects with convertAllProperties on', function (done) {
27+
config.convertAllProperties = true
28+
var vm = new Vue({
29+
el: el,
30+
data: {
31+
items: [{a: 1}, {a: 2}]
32+
},
33+
template: '<div v-for="item in items">{{$index}} {{item.a}}</div>'
34+
})
35+
assertMutations(vm, el, done)
36+
})
37+
2438
it('primitives', function (done) {
2539
var vm = new Vue({
2640
el: el,

0 commit comments

Comments
 (0)