This commit is contained in:
Pierre-Yves Gerardy 2017-05-29 17:19:55 +02:00
parent d21bfd4a36
commit 4616160a52
2 changed files with 21 additions and 10 deletions

View file

@ -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[0] === "o" && key[1] === "n" && typeof value === "function") updateEvent(vnode, key, value)
else if (key === "style") updateStyle(element, old, value) else if (key === "style") updateStyle(element, old, value)
else if (key in element && !isAttribute(key) && ns === undefined && !isCustomElement(vnode)) { 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 (key === "value") {
if (vnode.tag === "input" && key === "value" && vnode.dom.value == value && vnode.dom === $doc.activeElement) return /*eslint-disable no-implicit-coercion*/
//setting select[value] to same value while having select open blinks select dropdown in Chrome var normalized = "" + value
if (vnode.tag === "select" && key === "value" && vnode.dom.value == value && vnode.dom === $doc.activeElement) return /*eslint-enable no-implicit-coercion*/
//setting option[value] to same value while having select open blinks select dropdown in Chrome //setting input[value] to same value by typing on focused element moves cursor to end in Chrome
if (vnode.tag === "option" && key === "value" && old != null && vnode.dom.value == value) return 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 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") { if (vnode.tag === "input" && key === "type") {
element.setAttribute(key, value) element.setAttribute(key, value)

View file

@ -203,10 +203,10 @@ o.spec("attributes", function() {
o(b.dom.value).equals("") o(b.dom.value).equals("")
// #1595 redux // #1595 redux
render(root, [c]); 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() { o("isn't set when equivalent to the previous value and focused", function() {
var $window = domMock({spy: o.spy}) var $window = domMock({spy: o.spy})
@ -476,7 +476,7 @@ o.spec("attributes", function() {
o(a.dom.value).equals("") o(a.dom.value).equals("")
// #1595 redux // #1595 redux
render(root, [b]) render(root, [b])
o(b.dom.value).equals("0") o(b.dom.value).equals("0")