From f6e627a8916ac923eb2778a92c07031025ed493f Mon Sep 17 00:00:00 2001 From: Gampol T Date: Thu, 23 Feb 2017 17:45:25 +0700 Subject: [PATCH 1/2] fix state.update not destroy when edit text blank if (state.editing.title === "") should call state.destroy() instead of destroy() --- examples/todomvc/todomvc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/todomvc/todomvc.js b/examples/todomvc/todomvc.js index 1f1f257a..59099cf5 100644 --- a/examples/todomvc/todomvc.js +++ b/examples/todomvc/todomvc.js @@ -38,7 +38,7 @@ var state = { update: function(title) { if (state.editing != null) { state.editing.title = title.trim() - if (state.editing.title === "") destroy(state.editing) + if (state.editing.title === "") state.destroy(state.editing) state.editing = null } }, From 450570d4c9f2bc6da646d357d4fa59bd934f347f Mon Sep 17 00:00:00 2001 From: Gampol T Date: Thu, 23 Feb 2017 17:48:13 +0700 Subject: [PATCH 2/2] fix ui.save not detect escape key change event from onkeypress to onkeyup because onkeypress cannot detect escape key press if (e.keyCode === 27) --- examples/todomvc/todomvc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/todomvc/todomvc.js b/examples/todomvc/todomvc.js index 59099cf5..83d2a822 100644 --- a/examples/todomvc/todomvc.js +++ b/examples/todomvc/todomvc.js @@ -104,7 +104,7 @@ var Todos = { m("label", {ondblclick: function() {state.dispatch("edit", [todo])}}, todo.title), m("button.destroy", {onclick: function() {state.dispatch("destroy", [todo])}}), ]), - m("input.edit", {onupdate: function(vnode) {ui.focus(vnode, todo)}, onkeypress: ui.save, onblur: ui.save}) + m("input.edit", {onupdate: function(vnode) {ui.focus(vnode, todo)}, onkeyup: ui.save, onblur: ui.save}) ]) }), ]),