8 The reconciliation algorithm: Patching the DOM

 

This chapter covers

  • Implementing the patchDOM() function
  • Using the objectsDiff() function to find the differences in attributes and styles
  • Using the arraysDiff() function to find the differences between CSS classes
  • Using the arraysDiffSequence() function to find the differences between virtual DOM children
  • Using the Document API to patch DOM changes

In chapter 7, you saw how the reconciliation algorithm works in two phases: finding the differences between two virtual Document Object Model (DOM) trees and patching those differences in the real DOM. You implemented the three key functions to find differences between two objects or two arrays: objectsDiff(), arraysDiff(), and arraysDiffSequence(). In this chapter, you’ll use these functions to implement the reconciliation algorithm inside the patchDOM() function. patchDOM() finds the differences between two virtual DOM trees (the one that’s currently rendered and the one after the state has changed) and patches the real DOM accordingly.

8.1 Mounting the DOM at an index

 
 
 

8.1.1 The insert() function

 
 
 

8.1.2 Text nodes

 

8.1.3 Element nodes

 
 
 
 

8.1.4 Fragment nodes

 

8.2 Patching the DOM

 
 
 
 

8.2.1 The reconciliation algorithm

 
 
 
 

8.2.2 Virtual node equality

 
 

8.2.3 Subtree change

 
 
 

8.2.4 Patching text nodes

 
 

8.2.5 Patching element nodes

 
 

8.2.6 Patching child nodes

 
 
 
 

8.3 Publishing the framework’s new version

 
 

8.4 The TODOs application

 
 
 
 

8.4.1 Inspecting the DOM tree changes

 
 
 

Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage