Skip to content

Instantly share code, notes, and snippets.

@matthewp
Created October 31, 2018 15:21
Show Gist options
  • Save matthewp/ce8bb92673f130bc480a4acf8614e0f7 to your computer and use it in GitHub Desktop.
Save matthewp/ce8bb92673f130bc480a4acf8614e0f7 to your computer and use it in GitHub Desktop.
Sorting problem
<div>
<main id="main1"></main> 0
</div>
div.appendChild(main2);
div.removeChild(main1);
<div>
<main id="main2"></main> 0
</div>
[
Mutation<append>
Mutation<remove>
]
// WRONG
<div>
<main id="main1"></main>
</div>
// BETTER
div.appendChild(main2); // 1
// PATCH()
div.removeChild(main1); // 0
[
Mutation<append>
Mutation<remove>
]
<div>
<main id="main1"></main>
</div>
// BEST
[
Mutation<remove>
Mutation<append>
]
<div>
<main id="main1"></main>
</div>
// ordering
<div id="app">
<h1>Hello <span>World</span></h1> // [ADD SPAN]
<todos-list>
<ul>
<li>First</li> // [ADD]
<li>Second</li> // [RM]
</ul>
</todos-list>
</div>
[
Mutation<append span> 3
Mutation<append li> 5
Mutation<remove li> 5
]
[
Mutation<remove li>
Mutation<append li>
Mutation<append span>
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment