Skip to content

Commit

Permalink
treat <input> with different types as different nodes (fix #5266)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 24, 2017
1 parent 5222f06 commit f4630d0
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/core/vdom/patch.js
Expand Up @@ -34,15 +34,26 @@ function isTrue (v) {
return v === true
}

function sameVnode (vnode1, vnode2) {
function sameVnode (a, b) {
return (
vnode1.key === vnode2.key &&
vnode1.tag === vnode2.tag &&
vnode1.isComment === vnode2.isComment &&
!vnode1.data === !vnode2.data
a.key === b.key &&
a.tag === b.tag &&
a.isComment === b.isComment &&
isDef(a.data) === isDef(b.data) &&
sameInputType(a, b)
)
}

// Some browsers do not support dynamically changing type for <input>
// so they need to be treated as different nodes
function sameInputType (a, b) {
if (a.tag !== 'input') return true
let i
const typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type
const typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type
return typeA === typeB
}

function createKeyToOldIdx (children, beginIdx, endIdx) {
let i, key
const map = {}
Expand Down

0 comments on commit f4630d0

Please sign in to comment.