Given the following HTML:
<li data-id="1533501855500" class="completed"> <div class="view"> <input class="toggle" type="checkbox"> <label>Learn Elm Architecture</label> <button class="destroy"></button> </div> </li>
Use Elm
(ish) DOM functions (li
, div
, input
, label
and button
)
to render a single Todo List item.
<li>
should contain a <div>
with a class="view"
which "wraps":
<input class="toggle" type="checkbox">
- the "checkbox" that people can "Toggle" to change the "state" of the Todo item from "active" to "done" (_which updates the model From: model.todos[id].done=false
To: model.todos[id].done=true
<label>
- the text content of the todo list item<button class="destroy">
- the button the person can click/tap to delete
a Todo item.test.only('render_item HTML for a single Todo Item', function (t) { const model = { todos: [ { id: 1, title: "Learn Elm Architecture", done: true }, ], hash: '#/' // the "route" to display }; // render the ONE todo list item: document.getElementById(id).appendChild(app.render_item(model.todos[0])) const done = document.querySelectorAll('.completed')[0].textContent; t.equal(done, 'Learn Elm Architecture', 'Done: Learn "TEA"'); const checked = document.querySelectorAll('input')[0].checked; t.equal(checked, true, 'Done: ' + model.todos[0].title + " is done=true"); elmish.empty(document.getElementById(id)); // clear DOM ready for next test t.end(); });
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4