commit
712be2bcc3
2 changed files with 49 additions and 20 deletions
|
|
@ -480,12 +480,21 @@ 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
|
var normalized = "" + value // eslint-disable-line no-implicit-coercion
|
||||||
//setting select[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 === "select" && key === "value" && vnode.dom.value == value && vnode.dom === $doc.activeElement) return
|
if (vnode.tag === "input" && vnode.dom.value === normalized && vnode.dom === $doc.activeElement) return
|
||||||
//setting option[value] to same value while having select open blinks select dropdown in Chrome
|
//setting select[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 (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)
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,7 @@ o.spec("attributes", function() {
|
||||||
o("'' and 0 are different values", function() {
|
o("'' and 0 are different values", function() {
|
||||||
var a = {tag: "input", attrs: {value: 0}, children:[{tag:"#", children:""}]}
|
var a = {tag: "input", attrs: {value: 0}, children:[{tag:"#", children:""}]}
|
||||||
var b = {tag: "input", attrs: {value: ""}, children:[{tag:"#", children:""}]}
|
var b = {tag: "input", attrs: {value: ""}, children:[{tag:"#", children:""}]}
|
||||||
|
var c = {tag: "input", attrs: {value: 0}, children:[{tag:"#", children:""}]}
|
||||||
|
|
||||||
render(root, [a]);
|
render(root, [a]);
|
||||||
|
|
||||||
|
|
@ -200,13 +201,12 @@ o.spec("attributes", function() {
|
||||||
|
|
||||||
render(root, [b]);
|
render(root, [b]);
|
||||||
|
|
||||||
o(a.dom.value).equals("")
|
o(b.dom.value).equals("")
|
||||||
|
|
||||||
// #1959 redux
|
// #1595 redux
|
||||||
// TODO: UNCOMMENT
|
render(root, [c]);
|
||||||
// render(root, [a]);
|
|
||||||
|
|
||||||
// o(a.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})
|
||||||
|
|
@ -362,6 +362,7 @@ o.spec("attributes", function() {
|
||||||
o("'' and 0 are different values", function() {
|
o("'' and 0 are different values", function() {
|
||||||
var a = {tag: "option", attrs: {value: 0}, children:[{tag:"#", children:""}]}
|
var a = {tag: "option", attrs: {value: 0}, children:[{tag:"#", children:""}]}
|
||||||
var b = {tag: "option", attrs: {value: ""}, children:[{tag:"#", children:""}]}
|
var b = {tag: "option", attrs: {value: ""}, children:[{tag:"#", children:""}]}
|
||||||
|
var c = {tag: "option", attrs: {value: 0}, children:[{tag:"#", children:""}]}
|
||||||
|
|
||||||
render(root, [a]);
|
render(root, [a]);
|
||||||
|
|
||||||
|
|
@ -371,11 +372,10 @@ o.spec("attributes", function() {
|
||||||
|
|
||||||
o(a.dom.value).equals("")
|
o(a.dom.value).equals("")
|
||||||
|
|
||||||
// #1959 redux
|
// #1595 redux
|
||||||
// TODO: UNCOMMENT
|
render(root, [c]);
|
||||||
// render(root, [a]);
|
|
||||||
|
|
||||||
// o(a.dom.value).equals("0")
|
o(c.dom.value).equals("0")
|
||||||
})
|
})
|
||||||
o("isn't set when equivalent to the previous value", function() {
|
o("isn't set when equivalent to the previous value", function() {
|
||||||
var $window = domMock({spy: o.spy})
|
var $window = domMock({spy: o.spy})
|
||||||
|
|
@ -469,18 +469,38 @@ o.spec("attributes", function() {
|
||||||
})
|
})
|
||||||
o("'' and 0 are different values when focused", function() {
|
o("'' and 0 are different values when focused", function() {
|
||||||
var a = makeSelect("")
|
var a = makeSelect("")
|
||||||
// var b = makeSelect(0)
|
var b = makeSelect(0)
|
||||||
|
|
||||||
render(root, [a])
|
render(root, [a])
|
||||||
a.dom.focus()
|
a.dom.focus()
|
||||||
|
|
||||||
o(a.dom.value).equals("")
|
o(a.dom.value).equals("")
|
||||||
|
|
||||||
// #1959 redux
|
// #1595 redux
|
||||||
// TODO: UNCOMMENT
|
render(root, [b])
|
||||||
// render(root, [b])
|
|
||||||
|
|
||||||
// o(b.dom.value).equals("0")
|
o(b.dom.value).equals("0")
|
||||||
|
})
|
||||||
|
o("'' and null are different values when focused", function() {
|
||||||
|
var a = makeSelect("")
|
||||||
|
var b = makeSelect(null)
|
||||||
|
var c = makeSelect("")
|
||||||
|
|
||||||
|
render(root, [a])
|
||||||
|
a.dom.focus()
|
||||||
|
|
||||||
|
o(a.dom.value).equals("")
|
||||||
|
o(a.dom.selectedIndex).equals(4)
|
||||||
|
|
||||||
|
render(root, [b])
|
||||||
|
|
||||||
|
o(b.dom.value).equals("")
|
||||||
|
o(b.dom.selectedIndex).equals(-1)
|
||||||
|
|
||||||
|
render(root, [c])
|
||||||
|
|
||||||
|
o(c.dom.value).equals("")
|
||||||
|
o(c.dom.selectedIndex).equals(4)
|
||||||
})
|
})
|
||||||
o("updates with the same value do not re-set the attribute if the select has focus", function() {
|
o("updates with the same value do not re-set the attribute if the select has focus", function() {
|
||||||
var $window = domMock({spy: o.spy})
|
var $window = domMock({spy: o.spy})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue