remove deopts from example (#460)
This commit is contained in:
+16
-3
@@ -53,6 +53,7 @@ function todoStore (state, emitter) {
|
|||||||
state.todos.active = []
|
state.todos.active = []
|
||||||
state.todos.done = []
|
state.todos.done = []
|
||||||
state.todos.all = []
|
state.todos.all = []
|
||||||
|
state.todos.input = ''
|
||||||
|
|
||||||
state.todos.idCounter = 0
|
state.todos.idCounter = 0
|
||||||
}
|
}
|
||||||
@@ -65,6 +66,9 @@ function todoStore (state, emitter) {
|
|||||||
emitter.on('todos:update', update)
|
emitter.on('todos:update', update)
|
||||||
emitter.on('todos:delete', del)
|
emitter.on('todos:delete', del)
|
||||||
|
|
||||||
|
// Special
|
||||||
|
emitter.on('todos:input', oninput)
|
||||||
|
|
||||||
// Shorthand
|
// Shorthand
|
||||||
emitter.on('todos:edit', edit)
|
emitter.on('todos:edit', edit)
|
||||||
emitter.on('todos:unedit', unedit)
|
emitter.on('todos:unedit', unedit)
|
||||||
@@ -73,6 +77,10 @@ function todoStore (state, emitter) {
|
|||||||
emitter.on('todos:deleteCompleted', deleteCompleted)
|
emitter.on('todos:deleteCompleted', deleteCompleted)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function oninput (text) {
|
||||||
|
state.todos.input = text
|
||||||
|
}
|
||||||
|
|
||||||
function create (name) {
|
function create (name) {
|
||||||
var item = {
|
var item = {
|
||||||
id: state.todos.idCounter,
|
id: state.todos.idCounter,
|
||||||
@@ -245,11 +253,12 @@ function Footer (state, emit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Header (todos, emit) {
|
function Header (state, emit) {
|
||||||
return html`
|
return html`
|
||||||
<header class="header">
|
<header class="header">
|
||||||
<h1>todos</h1>
|
<h1>todos</h1>
|
||||||
<input class="new-todo"
|
<input class="new-todo"
|
||||||
|
value=${state.todos.input}
|
||||||
autofocus
|
autofocus
|
||||||
placeholder="What needs to be done?"
|
placeholder="What needs to be done?"
|
||||||
onkeydown=${createTodo} />
|
onkeydown=${createTodo} />
|
||||||
@@ -257,9 +266,13 @@ function Header (todos, emit) {
|
|||||||
`
|
`
|
||||||
|
|
||||||
function createTodo (e) {
|
function createTodo (e) {
|
||||||
|
var value = e.target.value
|
||||||
|
if (!value) return
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
emit('todos:create', e.target.value)
|
emit('todos:input', '')
|
||||||
e.target.value = ''
|
emit('todos:create', value)
|
||||||
|
} else {
|
||||||
|
emit('todos:input', value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user