GithubHelp home page GithubHelp logo

Comments (1)

DAreRodz avatar DAreRodz commented on June 1, 2024 2

@SantosGuillamot, I've been taking a look at this issue, and I think we can ignore the ref attribute while generating virtual nodes, i.e., something like:

diff --git a/src/runtime/vdom.js b/src/runtime/vdom.js
index 5657128..b11cec9 100644
--- a/src/runtime/vdom.js
+++ b/src/runtime/vdom.js
@@ -24,6 +24,8 @@ export default function toVdom(node) {
 			const [, prefix, suffix] = /wp-([^:]+):?(.*)$/.exec(n);
 			wpDirectives[prefix] = wpDirectives[prefix] || {};
 			wpDirectives[prefix][suffix || 'default'] = val;
+		} else if (n === 'ref') {
+			continue;
 		} else {
 			props[n] = attributes[i].value;
 		}

What does this imply? Practically nothing, because even if the ref attribute is not saved in the props generated by running toVdom(), the attribute remains in the DOM node after hydrating; it is not removed.

There could be problems if that node is in any part of the DOM that is unmounted and mounted again, in which case there would be two possibilities:

  1. The third-party library that handles the ref attribute has already been run before hydrate, so the changes it makes are most likely already in the DOM, and everything will work as usual.
  2. This third-party library runs after hydration; if that happens, when unmounting and re-mounting the node, it is most likely that this third-party library will not be executed again, so it doesn't matter if ref is there or not. 🤷

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.