Skip to content

Commit 72c83e3

Browse files
committed
add test: props should not convert non-reactive values
1 parent 80e956a commit 72c83e3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,4 +673,31 @@ describe('prop', function () {
673673
})
674674
expect(vm.$el.textContent).toBe('1')
675675
})
676+
677+
it('non reactive values passed down as prop should not be converted', function (done) {
678+
var a = Object.freeze({
679+
msg: 'hello'
680+
})
681+
var parent = new Vue({
682+
el: el,
683+
template: '<comp :a="a"></comp>',
684+
data: {
685+
a: a
686+
},
687+
components: {
688+
comp: {
689+
props: ['a']
690+
}
691+
}
692+
})
693+
var child = parent.$children[0]
694+
expect(child.a.msg).toBe('hello')
695+
expect(child.a.__ob__).toBeUndefined() // should not be converted
696+
parent.a = Object.freeze({ msg: 'yo' })
697+
Vue.nextTick(function () {
698+
expect(child.a.msg).toBe('yo')
699+
expect(child.a.__ob__).toBeUndefined()
700+
done()
701+
})
702+
})
676703
})

0 commit comments

Comments
 (0)