From e1856385d6167f5a2ef7e13b1fa1f83330006acf Mon Sep 17 00:00:00 2001 From: Christopher Baker Date: Wed, 14 Feb 2018 16:54:12 -0800 Subject: [PATCH] Cleanup markdown sample code (#44) * fix markdown code snippets * Use const/let in sample code * run eslint on markdown code * run eslint on markdown code --- can-view-nodelist.md | 18 +++--- docs/nodelists-blog-post.md | 114 ++++++++++++++++++++---------------- 2 files changed, 71 insertions(+), 61 deletions(-) diff --git a/can-view-nodelist.md b/can-view-nodelist.md index 728faec..3669503 100644 --- a/can-view-nodelist.md +++ b/can-view-nodelist.md @@ -37,7 +37,7 @@ The basic use is A `target` is going to be hydrated: ```js -target.hydrate(scope) +target.hydrate( scope ); ``` This will call the callbacks on placeholder elements. @@ -45,7 +45,7 @@ This will call the callbacks on placeholder elements. Those callbacks register their placeholder like this: ```js -nodeLists.register(nodeList = [placeholderElement], null) +nodeLists.register( nodeList = [ placeholderElement ], null ); ``` Then they render the content for the @@ -59,15 +59,15 @@ After the content renders, it will call: // this doesn't actually update the dom. But this will // detach any "old" nodeLists within `nodeList` // but oldNodes are all the nodes within the nodeLists -var oldNodes = nodeLists.update( - nodeList, - renderedContentFragment.childNodes ); +const oldNodes = nodeLists.update( + nodeList, + renderedContentFragment.childNodes ); ``` The children calling `.update()` end up adding to the parent `nodeList`'s `.replacements` array. `nodList` might look like: -```js +``` [ TEXT_NODE<> //original placeholder text node replacements: [ @@ -86,7 +86,7 @@ array. `nodList` might look like: When `.update` is called on `nodeList`, the `renderedContentFragment` will have the final content for what is being rendered. For example, it will be a fragment like: -```js +``` Items: @@ -97,7 +97,7 @@ Items: 1. Unregister any child nodeLists previously within `nodeList`. (there won't be any at this point) 2. Make a Map of the first node in a `replacements` nodeList to its nodelist: - ```js + ``` replacementsMap = Map({ [