Fix select option to use empty string value, add tests.
This commit is contained in:
parent
2aa6adf440
commit
0f9d5f1631
2 changed files with 42 additions and 1 deletions
|
|
@ -90,6 +90,47 @@ o.spec("form inputs", function() {
|
|||
o(select.dom.firstChild.value).equals("")
|
||||
})
|
||||
|
||||
o("option value defaults to textContent unless explicitly set", function() {
|
||||
var select = {tag: "select", children :[
|
||||
{tag: "option", text: "aaa"}
|
||||
]}
|
||||
|
||||
render(root, [select])
|
||||
|
||||
o(select.dom.firstChild.value).equals("aaa")
|
||||
o(select.dom.value).equals("aaa")
|
||||
|
||||
//test that value changes when content changes
|
||||
select = {tag: "select", children :[
|
||||
{tag: "option", text: "bbb"}
|
||||
]}
|
||||
|
||||
render(root, [select])
|
||||
|
||||
o(select.dom.firstChild.value).equals("bbb")
|
||||
o(select.dom.value).equals("bbb")
|
||||
|
||||
//test that value can be set to "" in subsequent render
|
||||
select = {tag: "select", children :[
|
||||
{tag: "option", attrs: {value: ""}, text: "aaa"}
|
||||
]}
|
||||
|
||||
render(root, [select])
|
||||
|
||||
o(select.dom.firstChild.value).equals("")
|
||||
o(select.dom.value).equals("")
|
||||
|
||||
//test that value reverts to textContent when value omitted
|
||||
select = {tag: "select", children :[
|
||||
{tag: "option", text: "ccc"}
|
||||
]}
|
||||
|
||||
render(root, [select])
|
||||
|
||||
o(select.dom.firstChild.value).equals("ccc")
|
||||
o(select.dom.value).equals("ccc")
|
||||
})
|
||||
|
||||
o("select yields invalid value without children", function() {
|
||||
var select = {tag: "select", attrs: {value: "a"}}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue