From 70e531685059542cfd0cdac3d59c96938ddc04a0 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Sat, 24 Feb 2024 12:48:15 +0100 Subject: [PATCH] Ignore HTML Elements in ReduxDevTools (#57497) --- packages/data/src/redux-store/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/data/src/redux-store/index.js b/packages/data/src/redux-store/index.js index 7fdc9331a2474..979c3127b9ed5 100644 --- a/packages/data/src/redux-store/index.js +++ b/packages/data/src/redux-store/index.js @@ -64,12 +64,16 @@ const mapValues = ( obj, callback ) => ] ) ); -// Convert Map objects to plain objects -const mapToObject = ( key, state ) => { +// Convert non serializable types to plain objects +const devToolsReplacer = ( key, state ) => { if ( state instanceof Map ) { return Object.fromEntries( state ); } + if ( state instanceof window.HTMLElement ) { + return null; + } + return state; }; @@ -421,7 +425,7 @@ function instantiateReduxStore( key, options, registry, thunkArgs ) { name: key, instanceId: key, serialize: { - replacer: mapToObject, + replacer: devToolsReplacer, }, } ) );