Skip to content

Commit e16caa0

Browse files
author
An Phan
committed
Remove warnings about inline value attributes for v-model (closes vuejs#4733)
1 parent 9d6c8ec commit e16caa0

File tree

2 files changed

+0
-41
lines changed

2 files changed

+0
-41
lines changed

src/platforms/web/compiler/directives/model.js

-17
Original file line numberDiff line numberDiff line change
@@ -159,23 +159,6 @@ function genDefaultModel (
159159
value: string,
160160
modifiers: ?ASTModifiers
161161
): ?boolean {
162-
if (process.env.NODE_ENV !== 'production') {
163-
if (el.tag === 'input' && el.attrsMap.value) {
164-
warn(
165-
`<${el.tag} v-model="${value}" value="${el.attrsMap.value}">:\n` +
166-
'inline value attributes will be ignored when using v-model. ' +
167-
'Declare initial values in the component\'s data option instead.'
168-
)
169-
}
170-
if (el.tag === 'textarea' && el.children.length) {
171-
warn(
172-
`<textarea v-model="${value}">:\n` +
173-
'inline content inside <textarea> will be ignored when using v-model. ' +
174-
'Declare initial values in the component\'s data option instead.'
175-
)
176-
}
177-
}
178-
179162
const type = el.attrsMap.type
180163
const { lazy, number, trim } = modifiers || {}
181164
const event = lazy || (isIE && type === 'range') ? 'change' : 'input'

test/unit/features/directives/model-text.spec.js

-24
Original file line numberDiff line numberDiff line change
@@ -204,30 +204,6 @@ describe('Directive v-model text', () => {
204204
})
205205
}
206206

207-
it('warn inline value attribute', () => {
208-
const vm = new Vue({
209-
data: {
210-
test: 'foo'
211-
},
212-
template: '<input v-model="test" value="bar">'
213-
}).$mount()
214-
expect(vm.test).toBe('foo')
215-
expect(vm.$el.value).toBe('foo')
216-
expect('inline value attributes will be ignored').toHaveBeenWarned()
217-
})
218-
219-
it('warn textarea inline content', function () {
220-
const vm = new Vue({
221-
data: {
222-
test: 'foo'
223-
},
224-
template: '<textarea v-model="test">bar</textarea>'
225-
}).$mount()
226-
expect(vm.test).toBe('foo')
227-
expect(vm.$el.value).toBe('foo')
228-
expect('inline content inside <textarea> will be ignored').toHaveBeenWarned()
229-
})
230-
231207
it('warn invalid tag', () => {
232208
new Vue({
233209
data: {

0 commit comments

Comments
 (0)