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 ## 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 [v0.1.11](/mithril/archive/v0.1.11) - maintenance
### News: ### News:

View file

@ -150,7 +150,7 @@ Mithril = m = new function app(window) {
else if (attrName === "value" && tag === "input") { else if (attrName === "value" && tag === "input") {
if (node.value !== dataAttr) node.value = dataAttr 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) else node.setAttribute(attrName, dataAttr)
} }
} }
@ -279,7 +279,9 @@ Mithril = m = new function app(window) {
else if (arguments[0].addEventListener) { else if (arguments[0].addEventListener) {
var element = arguments[0] var element = arguments[0]
var isInitialized = arguments[1] 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) { if (!isInitialized) {
element.removeEventListener("click", routeUnobtrusive) element.removeEventListener("click", routeUnobtrusive)
element.addEventListener("click", routeUnobtrusive) element.addEventListener("click", routeUnobtrusive)

View file

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