From ed6058a446ab8f82fb799046b0f85cbdd48e9c69 Mon Sep 17 00:00:00 2001 From: David Dios Date: Tue, 5 May 2020 20:00:54 +0100 Subject: [PATCH] add __v and __o keys to the custom handler to support Preact (#67) --- index.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 5098e2d..1301ff0 100644 --- a/index.js +++ b/index.js @@ -88,13 +88,17 @@ function equal(a, b) { // custom handling for DOM elements if (hasElementType && a instanceof Element) return false; - // custom handling for React + // custom handling for React/Preact for (i = length; i-- !== 0;) { - if (keys[i] === '_owner' && a.$$typeof) { - // React-specific: avoid traversing React elements' _owner. - // _owner contains circular references - // and is not needed when comparing the actual elements (and not their owners) - // .$$typeof and ._store on just reasonable markers of a react element + if ((keys[i] === '_owner' || keys[i] === '__v' || keys[i] === '__o') && a.$$typeof) { + // React-specific: avoid traversing React elements' _owner + // Preact-specific: avoid traversing Preact elements' __v and __o + // __v = $_original / $_vnode + // __o = $_owner + // These properties contain circular references and are not needed when + // comparing the actual elements (and not their owners) + // .$$typeof and ._store on just reasonable markers of elements + continue; }