Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Remove data attributes from being saved in html of All products block #10032

Merged
merged 13 commits into from
Sep 25, 2023
Merged
27 changes: 26 additions & 1 deletion assets/js/blocks/products/all-products/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,29 @@ const v1 = {
},
};

export default [ v1 ];
const v2 = {
save( { attributes } ) {
roykho marked this conversation as resolved.
Show resolved Hide resolved
const dataAttributes = {};
Object.keys( attributes )
.sort()
.forEach( ( key ) => {
dataAttributes[ key ] = attributes[ key ];
} );
const data = {
'data-attributes': JSON.stringify( dataAttributes ),
};
return (
<div
className={ getBlockClassName(
'wc-block-all-products',
attributes
) }
{ ...data }
>
<InnerBlocks.Content />
</div>
);
},
};

export default [ v1, v2 ];
roykho marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 0 additions & 4 deletions assets/js/blocks/products/all-products/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ export default function save( { attributes } ) {
.forEach( ( key ) => {
dataAttributes[ key ] = attributes[ key ];
} );
roykho marked this conversation as resolved.
Show resolved Hide resolved
const data = {
'data-attributes': JSON.stringify( dataAttributes ),
};
return (
<div
className={ getBlockClassName(
'wc-block-all-products',
attributes
) }
{ ...data }
>
<InnerBlocks.Content />
</div>
Expand Down