mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
Merge pull request #11 from Microsoft/update-null-node-docs
updaging step 3 docs
This commit is contained in:
@@ -13,6 +13,7 @@ This demo starts off with a few elements already in place. Let's walk through wh
|
|||||||
- **addTodo()** - This is the primary logic of our todo app. Here's how the lines break down.
|
- **addTodo()** - This is the primary logic of our todo app. Here's how the lines break down.
|
||||||
1. `todo` is set to equal the first todo item
|
1. `todo` is set to equal the first todo item
|
||||||
2. `newTodo` is a clone of todo. Passing true means it is a deep clone, so we get the todo's children as well. Cloning does not duplicate the DOM node. We'll need to insert it in step 4
|
2. `newTodo` is a clone of todo. Passing true means it is a deep clone, so we get the todo's children as well. Cloning does not duplicate the DOM node. We'll need to insert it in step 4
|
||||||
|
> Note that this approach is very fragile, as it requires a todo node to always be present on the page
|
||||||
3. We set the innerText of the `<span class='title'>` to the value returned from getTodoText
|
3. We set the innerText of the `<span class='title'>` to the value returned from getTodoText
|
||||||
> Note that if we left off the `()` we'd actually be assigning innerText to the 'function' instead of the function return
|
> Note that if we left off the `()` we'd actually be assigning innerText to the 'function' instead of the function return
|
||||||
4. Insert our new todo into the todo's parent (the `ul`), before our reference todo. [insertBefore](https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore)
|
4. Insert our new todo into the todo's parent (the `ul`), before our reference todo. [insertBefore](https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore)
|
||||||
|
|||||||
Reference in New Issue
Block a user