Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Replace remaining custom deep cloning with 'structuredClone'" #68135

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading