DEV Community

Discussion on: Building a Simple Virtual DOM from Scratch

Collapse
 
precosmicowl profile image
Kirill Vasiltsov • Edited

Very good job. Thank you for a thorough guide!
Actually, there is a typo in your code within the post.

  const additionalPatches = [];
  for (const additionalVChild of newVChildren.slice(oldVChildren.length)) {
    additionalPatches.push($node => {
      $node.appendChild(render(newVChildren));
      return $node;
    });
  }
Enter fullscreen mode Exit fullscreen mode

Inside the function that we put into additionalPatches we should render not the newVChildren but the additionalVChild.
This code appears in the first example in the explanation of diffChildren function.

Collapse
 
ycmjason profile image
YCM Jason

You are a hero! Thanks for pointing that out! 🎉🎉🎉 I'll change it as soon as possible!

Collapse
 
maiermic profile image
Michael Maier

This typo is still in the article 😉