Skip to content

Commit

Permalink
Remove warnings about inline value attributes for v-model (closes vue…
Browse files Browse the repository at this point in the history
  • Loading branch information
phanan authored and yyx990803 committed Jan 23, 2017
1 parent 9d6c8ec commit b4115f7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
17 changes: 0 additions & 17 deletions src/platforms/web/compiler/directives/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,6 @@ function genDefaultModel (
value: string,
modifiers: ?ASTModifiers
): ?boolean {
if (process.env.NODE_ENV !== 'production') {
if (el.tag === 'input' && el.attrsMap.value) {
warn(
`<${el.tag} v-model="${value}" value="${el.attrsMap.value}">:\n` +
'inline value attributes will be ignored when using v-model. ' +
'Declare initial values in the component\'s data option instead.'
)
}
if (el.tag === 'textarea' && el.children.length) {
warn(
`<textarea v-model="${value}">:\n` +
'inline content inside <textarea> will be ignored when using v-model. ' +
'Declare initial values in the component\'s data option instead.'
)
}
}

const type = el.attrsMap.type
const { lazy, number, trim } = modifiers || {}
const event = lazy || (isIE && type === 'range') ? 'change' : 'input'
Expand Down
24 changes: 0 additions & 24 deletions test/unit/features/directives/model-text.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,30 +204,6 @@ describe('Directive v-model text', () => {
})
}

it('warn inline value attribute', () => {
const vm = new Vue({
data: {
test: 'foo'
},
template: '<input v-model="test" value="bar">'
}).$mount()
expect(vm.test).toBe('foo')
expect(vm.$el.value).toBe('foo')
expect('inline value attributes will be ignored').toHaveBeenWarned()
})

it('warn textarea inline content', function () {
const vm = new Vue({
data: {
test: 'foo'
},
template: '<textarea v-model="test">bar</textarea>'
}).$mount()
expect(vm.test).toBe('foo')
expect(vm.$el.value).toBe('foo')
expect('inline content inside <textarea> will be ignored').toHaveBeenWarned()
})

it('warn invalid tag', () => {
new Vue({
data: {
Expand Down

0 comments on commit b4115f7

Please sign in to comment.