diff --git a/docs/change-log.md b/docs/change-log.md index 09b28302..087202a9 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -44,6 +44,7 @@ - core: `xlink:href` attributes are now correctly removed - core: render() function can no longer prevent from changing `document.activeElement` in lifecycle hooks - render: fixed an ommission that caused `oninit` to be called unnecessarily in some cases [#1992](https://github.com/MithrilJS/mithril.js/issues/1992) +- render: Render state correctly on select change event [#1916](https://github.com/MithrilJS/mithril.js/issues/1916) --- diff --git a/render/render.js b/render/render.js index 37855447..4fabfc45 100644 --- a/render/render.js +++ b/render/render.js @@ -551,7 +551,7 @@ module.exports = function($window) { } } function isFormAttribute(vnode, attr) { - return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === $doc.activeElement + return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === $doc.activeElement || vnode.dom.parentNode === $doc.activeElement } function isLifecycleMethod(attr) { return attr === "oninit" || attr === "oncreate" || attr === "onupdate" || attr === "onremove" || attr === "onbeforeremove" || attr === "onbeforeupdate" diff --git a/render/tests/test-attributes.js b/render/tests/test-attributes.js index d54ed9d4..62cb4196 100644 --- a/render/tests/test-attributes.js +++ b/render/tests/test-attributes.js @@ -462,6 +462,19 @@ o.spec("attributes", function() { {tag:"option", attrs: {value: ""}} ]} } + /* FIXME + This incomplete test is meant for testing #1916. + However it cannot be completed until #1978 is addressed + which is a lack a working select.selected / option.selected + attribute. Ask isiahmeadows. + + o("render select options", function() { + var select = {tag: "select", selectedIndex: 0, children: [ + {tag:"option", attrs: {value: "1", selected: ""}} + ]} + render(root, select) + }) + */ o("can be set as text", function() { var a = makeSelect() var b = makeSelect("2")