Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pygy committed May 29, 2017
1 parent d21bfd4 commit 4616160
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
23 changes: 17 additions & 6 deletions render/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,23 @@ module.exports = function($window) {
else if (key[0] === "o" && key[1] === "n" && typeof value === "function") updateEvent(vnode, key, value)
else if (key === "style") updateStyle(element, old, value)
else if (key in element && !isAttribute(key) && ns === undefined && !isCustomElement(vnode)) {
//setting input[value] to same value by typing on focused element moves cursor to end in Chrome
if (vnode.tag === "input" && key === "value" && vnode.dom.value == value && vnode.dom === $doc.activeElement) return
//setting select[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "select" && key === "value" && vnode.dom.value == value && vnode.dom === $doc.activeElement) return
//setting option[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "option" && key === "value" && old != null && vnode.dom.value == value) return
if (key === "value") {
/*eslint-disable no-implicit-coercion*/
var normalized = "" + value
/*eslint-enable no-implicit-coercion*/
//setting input[value] to same value by typing on focused element moves cursor to end in Chrome
if (vnode.tag === "input" && vnode.dom.value === normalized && vnode.dom === $doc.activeElement) return
//setting select[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "select") {
if (value === null) {
if (vnode.dom.selectedIndex === -1 && vnode.dom === $doc.activeElement) return
} else {
if (old !== null && vnode.dom.value === normalized && vnode.dom === $doc.activeElement) return
}
}
//setting option[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "option" && old != null && vnode.dom.value === normalized) return
}
// If you assign an input type that is not supported by IE 11 with an assignment expression, an error will occur.
if (vnode.tag === "input" && key === "type") {
element.setAttribute(key, value)
Expand Down
8 changes: 4 additions & 4 deletions render/tests/test-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ o.spec("attributes", function() {

o(b.dom.value).equals("")

// #1595 redux
render(root, [c]);
// #1595 redux
render(root, [c]);

o(c.dom.value).equals("0")
o(c.dom.value).equals("0")
})
o("isn't set when equivalent to the previous value and focused", function() {
var $window = domMock({spy: o.spy})
Expand Down Expand Up @@ -476,7 +476,7 @@ o.spec("attributes", function() {

o(a.dom.value).equals("")

// #1595 redux
// #1595 redux
render(root, [b])

o(b.dom.value).equals("0")
Expand Down

0 comments on commit 4616160

Please sign in to comment.