Skip to content

Commit ab0a225

Browse files
committed
Revert "also bind static special attrs as props (fix #4530)"
This reverts commit b3ebfef.
1 parent 4e830ba commit ab0a225

File tree

3 files changed

+1
-43
lines changed

3 files changed

+1
-43
lines changed

src/compiler/parser/index.js

-9
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,6 @@ function processAttrs (el) {
477477
}
478478
}
479479
addAttr(el, name, JSON.stringify(value))
480-
// #4530 also bind special attributes as props even if they are static
481-
// so that patches between dynamic/static are consistent
482-
if (platformMustUseProp(el.tag, name)) {
483-
if (name === 'value') {
484-
addProp(el, name, JSON.stringify(value))
485-
} else {
486-
addProp(el, name, 'true')
487-
}
488-
}
489480
}
490481
}
491482
}

test/unit/modules/compiler/parser.spec.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ describe('parser', () => {
413413

414414
it('literal attribute', () => {
415415
// basic
416-
const ast1 = parse('<input type="text" name="field1" value="hello world" checked>', baseOptions)
416+
const ast1 = parse('<input type="text" name="field1" value="hello world">', baseOptions)
417417
expect(ast1.attrsList[0].name).toBe('type')
418418
expect(ast1.attrsList[0].value).toBe('text')
419419
expect(ast1.attrsList[1].name).toBe('name')
@@ -429,13 +429,6 @@ describe('parser', () => {
429429
expect(ast1.attrs[1].value).toBe('"field1"')
430430
expect(ast1.attrs[2].name).toBe('value')
431431
expect(ast1.attrs[2].value).toBe('"hello world"')
432-
expect(ast1.attrs[3].name).toBe('checked')
433-
expect(ast1.attrs[3].value).toBe('""')
434-
// also bind speicals as props
435-
expect(ast1.props[0].name).toBe('value')
436-
expect(ast1.props[0].value).toBe('"hello world"')
437-
expect(ast1.props[1].name).toBe('checked')
438-
expect(ast1.props[1].value).toBe('true')
439432
// interpolation warning
440433
parse('<input type="text" name="field1" value="{{msg}}">', baseOptions)
441434
expect('Interpolation inside attributes has been removed').toHaveBeenWarned()

test/unit/modules/vdom/patch/edge-cases.spec.js

-26
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,4 @@ describe('vdom patch: edge cases', () => {
114114
})
115115
.then(done)
116116
})
117-
118-
// #4530
119-
it('should not reset value when patching bewteen dyanmic/static bindings', done => {
120-
const vm = new Vue({
121-
data: { ok: true },
122-
template: `
123-
<div>
124-
<input v-if="ok" value="a">
125-
<input v-else :value="'b'">
126-
<input v-if="ok" type="checkbox" checked>
127-
<input v-else type="checkbox" :checked="false">
128-
</div>
129-
`
130-
}).$mount()
131-
expect(vm.$el.children[0].value).toBe('a')
132-
expect(vm.$el.children[1].checked).toBe(true)
133-
vm.ok = false
134-
waitForUpdate(() => {
135-
expect(vm.$el.children[0].value).toBe('b')
136-
expect(vm.$el.children[1].checked).toBe(false)
137-
vm.ok = true
138-
}).then(() => {
139-
expect(vm.$el.children[0].value).toBe('a')
140-
expect(vm.$el.children[1].checked).toBe(true)
141-
}).then(done)
142-
})
143117
})

0 commit comments

Comments
 (0)