Skip to content

Commit

Permalink
Add block deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Aug 2, 2022
1 parent fac49f7 commit ee218ac
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion assets/js/blocks/products/all-products/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@ import { getBlockClassName } from '../utils.js';

const { attributes: attributeDefinitions } = metadata;

const v2 = {
attributes: attributeDefinitions,
save( { attributes } ) {
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>
);
},
};

const v1 = {
attributes: Object.assign( {}, attributeDefinitions, {
rows: { type: 'number', default: 1 },
Expand All @@ -33,4 +60,4 @@ const v1 = {
},
};

export default [ v1 ];
export default [ v2, v1 ];

0 comments on commit ee218ac

Please sign in to comment.