From ee218acc96fe0ca08da58c5f7babe5df0c1848f5 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Tue, 2 Aug 2022 15:12:37 +0200 Subject: [PATCH] Add block deprecation --- .../products/all-products/deprecated.js | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/assets/js/blocks/products/all-products/deprecated.js b/assets/js/blocks/products/all-products/deprecated.js index 5a5aadbf684..89c5a79aee2 100644 --- a/assets/js/blocks/products/all-products/deprecated.js +++ b/assets/js/blocks/products/all-products/deprecated.js @@ -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 ( +
+ +
+ ); + }, +}; + const v1 = { attributes: Object.assign( {}, attributeDefinitions, { rows: { type: 'number', default: 1 }, @@ -33,4 +60,4 @@ const v1 = { }, }; -export default [ v1 ]; +export default [ v2, v1 ];