fix datalist and link redraw

This commit is contained in:
Leo Horie 2014-05-06 22:26:30 -04:00
parent da69bc4fa0
commit deeb73973f
3 changed files with 20 additions and 3 deletions

View file

@ -1,5 +1,15 @@
## Change Log
[v0.1.12](/mithril/archive/v0.1.12) - maintenance
### Bug Fixes:
- Fix link location in links using `config: m.route` after redraws [#74](https://github.com/lhorie/mithril.js/issues/74)
- Fixed support for `list` attribute in inputs [#69](https://github.com/lhorie/mithril.js/issues/69)
---
[v0.1.11](/mithril/archive/v0.1.11) - maintenance
### News:

View file

@ -150,7 +150,7 @@ Mithril = m = new function app(window) {
else if (attrName === "value" && tag === "input") {
if (node.value !== dataAttr) node.value = dataAttr
}
else if (attrName in node) node[attrName] = dataAttr
else if (attrName in node && attrName != "list") node[attrName] = dataAttr
else node.setAttribute(attrName, dataAttr)
}
}
@ -279,7 +279,9 @@ Mithril = m = new function app(window) {
else if (arguments[0].addEventListener) {
var element = arguments[0]
var isInitialized = arguments[1]
element.href = location.pathname + modes[m.route.mode] + element.pathname
if (element.href.indexOf(modes[m.route.mode]) < 0) {
element.href = location.pathname + modes[m.route.mode] + element.pathname
}
if (!isInitialized) {
element.removeEventListener("click", routeUnobtrusive)
element.addEventListener("click", routeUnobtrusive)

View file

@ -13,10 +13,15 @@ app.controller = function() {
app.view = function(ctrl) {
return m("body", [
m("h1", ["Title: ", ctrl.title()]),
m("input", {
m("input[list=data]", {
onkeyup: m.withAttr("value", ctrl.title),
value: ctrl.title()
}),
m("datalist#data", [
m("option", "John"),
m("option", "Bob"),
m("option", "Mary")
]),
m("br"),
m("textarea", {
onkeyup: m.withAttr("value", ctrl.title),