Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. const html = require('choo/html')
  2.  
  3. const list = [
  4. 'wow',
  5. 'hey',
  6. 'cool'
  7. ]
  8.  
  9. const root = app(list)
  10. document.body.appendChild(root)
  11.  
  12. function app (list) {
  13. return html`
  14. <main>
  15. <input placeholder='filter' onkeyup=${e => filter(e)} />
  16. <ul>
  17. ${list.map(item => {
  18. return html`<li>${item}</li>`
  19. })}
  20. </ul>
  21. </main>
  22. `
  23. }
  24.  
  25. function filter (e) {
  26. const newList = list.filter(item => {
  27. return item.indexOf(e.target.value) > -1
  28. })
  29.  
  30. const newEl = app(newList)
  31. html.update(root, newEl)
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement