Skip to content

Commit

Permalink
Revert "Replace remaining custom deep cloning with 'structuredClone' (#…
Browse files Browse the repository at this point in the history
…67707)"

This reverts commit ad0c1d4.
  • Loading branch information
Mamaduka committed Dec 19, 2024
1 parent a4abb4d commit 814704b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ function pickStyleKeys( treeToPickFrom ) {
// clone the style objects so that `getFeatureDeclarations` can remove consumed keys from it
const clonedEntries = pickedEntries.map( ( [ key, style ] ) => [
key,
structuredClone( style ),
JSON.parse( JSON.stringify( style ) ),
] );
return Object.fromEntries( clonedEntries );
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/hooks/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export function omitStyle( style, paths, preserveReference = false ) {

let newStyle = style;
if ( ! preserveReference ) {
newStyle = structuredClone( style );
newStyle = JSON.parse( JSON.stringify( style ) );
}

if ( ! Array.isArray( paths ) ) {
Expand Down
4 changes: 0 additions & 4 deletions test/unit/config/global-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import { TextDecoder, TextEncoder } from 'node:util';
import { Blob as BlobPolyfill, File as FilePolyfill } from 'node:buffer';
import 'core-js/stable/structured-clone';

jest.mock( '@wordpress/compose', () => {
return {
Expand Down Expand Up @@ -50,6 +49,3 @@ if ( ! global.TextEncoder ) {
// Override jsdom built-ins with native node implementation.
global.Blob = BlobPolyfill;
global.File = FilePolyfill;

// Polyfill structuredClone for jsdom.
global.structuredClone = structuredClone;

0 comments on commit 814704b

Please sign in to comment.