Skip to content

Commit f4630d0

Browse files
committed
treat <input> with different types as different nodes (fix vuejs#5266)
1 parent 5222f06 commit f4630d0

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/core/vdom/patch.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,26 @@ function isTrue (v) {
3434
return v === true
3535
}
3636

37-
function sameVnode (vnode1, vnode2) {
37+
function sameVnode (a, b) {
3838
return (
39-
vnode1.key === vnode2.key &&
40-
vnode1.tag === vnode2.tag &&
41-
vnode1.isComment === vnode2.isComment &&
42-
!vnode1.data === !vnode2.data
39+
a.key === b.key &&
40+
a.tag === b.tag &&
41+
a.isComment === b.isComment &&
42+
isDef(a.data) === isDef(b.data) &&
43+
sameInputType(a, b)
4344
)
4445
}
4546

47+
// Some browsers do not support dynamically changing type for <input>
48+
// so they need to be treated as different nodes
49+
function sameInputType (a, b) {
50+
if (a.tag !== 'input') return true
51+
let i
52+
const typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type
53+
const typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type
54+
return typeA === typeB
55+
}
56+
4657
function createKeyToOldIdx (children, beginIdx, endIdx) {
4758
let i, key
4859
const map = {}

0 commit comments

Comments
 (0)