From 932739fd686fb570799d2e152d9a3015bdd86094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Mon, 3 Aug 2020 18:38:19 +0200 Subject: [PATCH] Remove 'is-loading' class requirement --- assets/js/base/utils/render-frontend.js | 3 -- .../js/blocks/products/all-products/index.js | 41 +++---------------- assets/js/blocks/reviews/all-reviews/index.js | 25 +++++------ assets/js/blocks/reviews/deprecated.js | 23 ----------- .../reviews/reviews-by-category/index.js | 39 ++++++++---------- .../reviews/reviews-by-product/index.js | 23 ++++------- 6 files changed, 42 insertions(+), 112 deletions(-) delete mode 100644 assets/js/blocks/reviews/deprecated.js diff --git a/assets/js/base/utils/render-frontend.js b/assets/js/base/utils/render-frontend.js index c6e859d07a7..0f1c0c15bf2 100644 --- a/assets/js/base/utils/render-frontend.js +++ b/assets/js/base/utils/render-frontend.js @@ -41,9 +41,6 @@ const renderBlockFrontend = ( { // Use Array.forEach for IE11 compatibility. Array.prototype.forEach.call( containers, ( el, i ) => { - if ( ! el.classList.contains( 'is-loading' ) ) { - return; - } for ( let j = 0; j < parentSelectorsToSkip.length; j++ ) { if ( el.parentNode.closest( parentSelectorsToSkip[ j ] ) ) { return; diff --git a/assets/js/blocks/products/all-products/index.js b/assets/js/blocks/products/all-products/index.js index 7a4e2907015..317e157d5b8 100644 --- a/assets/js/blocks/products/all-products/index.js +++ b/assets/js/blocks/products/all-products/index.js @@ -5,7 +5,6 @@ import { __ } from '@wordpress/i18n'; import { InnerBlocks } from '@wordpress/block-editor'; import { registerBlockType } from '@wordpress/blocks'; import { Icon, grid } from '@woocommerce/icons'; -import classNames from 'classnames'; import '@woocommerce/atomic-blocks'; /** @@ -64,9 +63,9 @@ const blockSettings = { }; return (
@@ -81,10 +80,10 @@ const blockSettings = { */ registerBlockType( 'woocommerce/all-products', { ...blockSettings, + /** + * Deprecation rule to handle the previous default rows which was 1 instead of 3. + */ deprecated: [ - /** - * Deprecation rule to handle the previous default rows which was 1 instead of 3. - */ { attributes: Object.assign( {}, blockSettings.attributes, { rows: { type: 'number', default: 1 }, @@ -106,33 +105,5 @@ registerBlockType( 'woocommerce/all-products', { ); }, }, - /** - * Deprecation rule to handle the block without the 'is-loading' class. - */ - { - attributes: blockSettings.attributes, - save( { attributes } ) { - const dataAttributes = {}; - Object.keys( attributes ) - .sort() - .forEach( ( key ) => { - dataAttributes[ key ] = attributes[ key ]; - } ); - const data = { - 'data-attributes': JSON.stringify( dataAttributes ), - }; - return ( -
- -
- ); - }, - }, ], } ); diff --git a/assets/js/blocks/reviews/all-reviews/index.js b/assets/js/blocks/reviews/all-reviews/index.js index 9f1d1d9aff8..2700ce0ffc3 100644 --- a/assets/js/blocks/reviews/all-reviews/index.js +++ b/assets/js/blocks/reviews/all-reviews/index.js @@ -12,20 +12,8 @@ import '../editor.scss'; import Editor from './edit'; import sharedAttributes from '../attributes'; import save from '../save.js'; -import getDeprecatedProperty from '../deprecated.js'; import { example } from '../example'; -const attributes = { - ...sharedAttributes, - /** - * Show the product name. - */ - showProductName: { - type: 'boolean', - default: true, - }, -}; - /** * Register and run the "All Reviews" block. * This block lists all product reviews. @@ -52,7 +40,16 @@ registerBlockType( 'woocommerce/all-reviews', { showProductName: true, }, }, - attributes, + attributes: { + ...sharedAttributes, + /** + * Show the product name. + */ + showProductName: { + type: 'boolean', + default: true, + }, + }, /** * Renders and manages the block. @@ -67,6 +64,4 @@ registerBlockType( 'woocommerce/all-reviews', { * Save the props to post content. */ save, - - deprecated: getDeprecatedProperty( attributes ), } ); diff --git a/assets/js/blocks/reviews/deprecated.js b/assets/js/blocks/reviews/deprecated.js deleted file mode 100644 index f55ecde2d3a..00000000000 --- a/assets/js/blocks/reviews/deprecated.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Internal dependencies - */ -import { getBlockClassName, getDataAttrs } from './utils.js'; - -export default function getDeprecatedProperty( atts ) { - return [ - /** - * Deprecation rule to handle the block without the 'is-loading' class. - */ - { - attributes: atts, - save( { attributes } ) { - return ( -
- ); - }, - }, - ]; -} diff --git a/assets/js/blocks/reviews/reviews-by-category/index.js b/assets/js/blocks/reviews/reviews-by-category/index.js index 95660e61263..1bf37f1407b 100644 --- a/assets/js/blocks/reviews/reviews-by-category/index.js +++ b/assets/js/blocks/reviews/reviews-by-category/index.js @@ -11,27 +11,8 @@ import { Icon, review } from '@woocommerce/icons'; import Editor from './edit'; import sharedAttributes from '../attributes'; import save from '../save.js'; -import getDeprecatedProperty from '../deprecated.js'; import { example } from '../example'; -const attributes = { - ...sharedAttributes, - /** - * The ids of the categories to load reviews for. - */ - categoryIds: { - type: 'array', - default: [], - }, - /** - * Show the product name. - */ - showProductName: { - type: 'boolean', - default: true, - }, -}; - /** * Register and run the "Reviews by category" block. */ @@ -58,7 +39,23 @@ registerBlockType( 'woocommerce/reviews-by-category', { showProductName: true, }, }, - attributes, + attributes: { + ...sharedAttributes, + /** + * The ids of the categories to load reviews for. + */ + categoryIds: { + type: 'array', + default: [], + }, + /** + * Show the product name. + */ + showProductName: { + type: 'boolean', + default: true, + }, + }, /** * Renders and manages the block. @@ -73,6 +70,4 @@ registerBlockType( 'woocommerce/reviews-by-category', { * Save the props to post content. */ save, - - deprecated: getDeprecatedProperty( attributes ), } ); diff --git a/assets/js/blocks/reviews/reviews-by-product/index.js b/assets/js/blocks/reviews/reviews-by-product/index.js index c17402fe17e..49418974a3a 100644 --- a/assets/js/blocks/reviews/reviews-by-product/index.js +++ b/assets/js/blocks/reviews/reviews-by-product/index.js @@ -11,19 +11,8 @@ import '../editor.scss'; import Editor from './edit'; import sharedAttributes from '../attributes'; import save from '../save.js'; -import getDeprecatedProperty from '../deprecated.js'; import { example } from '../example'; -const attributes = { - ...sharedAttributes, - /** - * The id of the product to load reviews for. - */ - productId: { - type: 'number', - }, -}; - /** * Register and run the "Reviews by Product" block. */ @@ -49,7 +38,15 @@ registerBlockType( 'woocommerce/reviews-by-product', { productId: 1, }, }, - attributes, + attributes: { + ...sharedAttributes, + /** + * The id of the product to load reviews for. + */ + productId: { + type: 'number', + }, + }, /** * Renders and manages the block. @@ -64,6 +61,4 @@ registerBlockType( 'woocommerce/reviews-by-product', { * Save the props to post content. */ save, - - deprecated: getDeprecatedProperty( attributes ), } );