Skip to content

Commit 30e9eda

Browse files
committed
should not skip observation for non-simple-path props (fix vuejs#2516)
1 parent 4e4cbe3 commit 30e9eda

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/compiler/compile-props.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import config from '../config'
22
import { parseDirective } from '../parsers/directive'
3+
import { isSimplePath } from '../parsers/expression'
34
import { defineReactive } from '../observer/index'
45
import propDef from '../directives/internal/prop'
56
import {
@@ -221,7 +222,8 @@ export function initProp (vm, prop, value) {
221222
value = getPropDefaultValue(vm, prop.options)
222223
}
223224
if (assertProp(prop, value)) {
224-
defineReactive(vm, key, value, true /* doNotObserve */)
225+
var doNotObserve = !prop.dynamic || isSimplePath(prop.raw)
226+
defineReactive(vm, key, value, doNotObserve)
225227
}
226228
}
227229

test/unit/specs/directives/internal/prop_spec.js

+19
Original file line numberDiff line numberDiff line change
@@ -700,4 +700,23 @@ describe('prop', function () {
700700
done()
701701
})
702702
})
703+
704+
it('inline prop values should be converted', function (done) {
705+
var vm = new Vue({
706+
el: el,
707+
template: '<comp :a="[1, 2, 3]"></comp>',
708+
components: {
709+
comp: {
710+
props: ['a'],
711+
template: '<div v-for="i in a">{{ i }}</div>'
712+
}
713+
}
714+
})
715+
expect(vm.$el.textContent).toBe('123')
716+
vm.$children[0].a.pop()
717+
Vue.nextTick(function () {
718+
expect(vm.$el.textContent).toBe('12')
719+
done()
720+
})
721+
})
703722
})

0 commit comments

Comments
 (0)