Skip to content

Commit c94d04d

Browse files
committed
warn against incorrect propsData usage
1 parent 9f6c23f commit c94d04d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/util/options.js

+5
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ function guardArrayAssets (assets) {
325325
export function mergeOptions (parent, child, vm) {
326326
guardComponents(child)
327327
guardProps(child)
328+
if (process.env.NODE_ENV !== 'production') {
329+
if (child.propsData && !vm) {
330+
warn('propsData can only be used as an instantiation option.')
331+
}
332+
}
328333
var options = {}
329334
var key
330335
if (child.mixins) {

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

+9
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,15 @@ describe('prop', function () {
615615
expect(vm.a).toBe(123)
616616
})
617617

618+
it('should warn using propsData during extension', function () {
619+
Vue.extend({
620+
propsData: {
621+
a: 123
622+
}
623+
})
624+
expect('propsData can only be used as an instantiation option').toHaveBeenWarned()
625+
})
626+
618627
it('should not warn for non-required, absent prop', function () {
619628
new Vue({
620629
el: el,

0 commit comments

Comments
 (0)