GithubHelp home page GithubHelp logo

Comments (5)

luisherranz avatar luisherranz commented on June 15, 2024 2

I've opened an issue in Preact's repo:

cc: @DAreRodz @michalczaplinski

from block-interactivity-experiments.

luisherranz avatar luisherranz commented on June 15, 2024

Ok, so this doesn't seem to be a bug in Preact, but the expected behavior.

I would try the following implementation here:

  • While doing the DOM -> vDOM (toVdom), remove the comments from the DOM, but keep the string and a reference to its location (parent or previous sibling).
  • Right after the hydrate, add them back.

from block-interactivity-experiments.

luisherranz avatar luisherranz commented on June 15, 2024

This seems to work fine. It should be just as fast, if not faster:

- const children = [].map.call(node.childNodes, toVdom).filter(exists);
+ const children = [];
+ for (let i = 0; i < childNodes.length; i++) {
+   const child = childNodes[i];
+   if (child.nodeType === 8) {
+     child.remove();
+     i--;
+   } else {
+     children.push(toVdom(child));
+   }
+ }

Kudos to @DAreRodz for noticing that we need to modify the index when removing child nodes.

from block-interactivity-experiments.

luisherranz avatar luisherranz commented on June 15, 2024

Let's not add the comments back just yet to avoid introducing complexity prematurely and see what happens when we test this in real sites.

from block-interactivity-experiments.

luisherranz avatar luisherranz commented on June 15, 2024

Already solved in #84.

from block-interactivity-experiments.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.