Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const html = require('choo/html')
- const list = [
- 'wow',
- 'hey',
- 'cool'
- ]
- const root = app(list)
- document.body.appendChild(root)
- function app (list) {
- return html`
- <main>
- <input placeholder='filter' onkeyup=${e => filter(e)} />
- <ul>
- ${list.map(item => {
- return html`<li>${item}</li>`
- })}
- </ul>
- </main>
- `
- }
- function filter (e) {
- const newList = list.filter(item => {
- return item.indexOf(e.target.value) > -1
- })
- const newEl = app(newList)
- html.update(root, newEl)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement