Skip to content

Commit

Permalink
add __v and __o keys to the custom handler to support Preact (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
dios-david authored May 5, 2020
1 parent 271b81b commit ed6058a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ed6058a

Please sign in to comment.