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

Commit

Permalink
Remove 'is-loading' class requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu committed Aug 3, 2020
1 parent 7d6adb2 commit 932739f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 112 deletions.
3 changes: 0 additions & 3 deletions assets/js/base/utils/render-frontend.js
Expand Up @@ -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;
Expand Down
41 changes: 6 additions & 35 deletions assets/js/blocks/products/all-products/index.js
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -64,9 +63,9 @@ const blockSettings = {
};
return (
<div
className={ classNames(
'is-loading',
getBlockClassName( 'wc-block-all-products', attributes )
className={ getBlockClassName(
'wc-block-all-products',
attributes
) }
{ ...data }
>
Expand All @@ -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 },
Expand All @@ -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 (
<div
className={ getBlockClassName(
'wc-block-all-products',
attributes
) }
{ ...data }
>
<InnerBlocks.Content />
</div>
);
},
},
],
} );
25 changes: 10 additions & 15 deletions assets/js/blocks/reviews/all-reviews/index.js
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -67,6 +64,4 @@ registerBlockType( 'woocommerce/all-reviews', {
* Save the props to post content.
*/
save,

deprecated: getDeprecatedProperty( attributes ),
} );
23 changes: 0 additions & 23 deletions assets/js/blocks/reviews/deprecated.js

This file was deleted.

39 changes: 17 additions & 22 deletions assets/js/blocks/reviews/reviews-by-category/index.js
Expand Up @@ -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.
*/
Expand All @@ -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.
Expand All @@ -73,6 +70,4 @@ registerBlockType( 'woocommerce/reviews-by-category', {
* Save the props to post content.
*/
save,

deprecated: getDeprecatedProperty( attributes ),
} );
23 changes: 9 additions & 14 deletions assets/js/blocks/reviews/reviews-by-product/index.js
Expand Up @@ -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.
*/
Expand All @@ -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.
Expand All @@ -64,6 +61,4 @@ registerBlockType( 'woocommerce/reviews-by-product', {
* Save the props to post content.
*/
save,

deprecated: getDeprecatedProperty( attributes ),
} );

0 comments on commit 932739f

Please sign in to comment.