GithubHelp home page GithubHelp logo

Support key for memoization about reef HOT 3 OPEN

cferdinandi avatar cferdinandi commented on September 25, 2024
Support key for memoization

from reef.

Comments (3)

duhdugg avatar duhdugg commented on September 25, 2024

something like this?

diff --git a/src/components/render.js b/src/components/render.js
index 265b265..8bedce1 100755
--- a/src/components/render.js
+++ b/src/components/render.js
@@ -212,6 +212,7 @@ function isDifferentNode (node1, node2) {
 		(typeof node1.nodeType === 'number' && node1.nodeType !== node2.nodeType) ||
 		(typeof node1.tagName === 'string' && node1.tagName !== node2.tagName) ||
 		(typeof node1.id === 'string' && node1.id !== node2.id) ||
+		(node1.getAttribute?.call(node1, 'key') !== node2.getAttribute?.call(node2, 'key')) ||
 		(typeof node1.src === 'string' && node1.src !== node2.src)
 	);
 }

from reef.

cferdinandi avatar cferdinandi commented on September 25, 2024

@duhdugg yea, though I don't think you need to the optional chaining operator/call() method on that one. I think you can just test it outright since strings and such don't generally make it to the test. I could be wrong.

from reef.

duhdugg avatar duhdugg commented on September 25, 2024

I'm having a little trouble following everything that might be passed to it, but I think you're right. The biggest user of this function is the diff function, which is used by render. There is a possibility that the wrong elem argument is provided to render, but this already causes an uncaught exception earlier in the diff function as it tries to access the childNodes property on a null value.

I'll submit a PR with no optional chaining.

from reef.

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.