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

Commit b7fddf7

Browse files
Aljullumikejolley
authored andcommitted
Use renderFrontend function to render the Price Filter block in the frontend (#1136)
* Fix minor issues in comments * Use renderFrontend function for price filter
1 parent 84bf289 commit b7fddf7

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

assets/js/base/components/review-list-item/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ ReviewListItem.propTypes = {
203203

204204
/**
205205
* BE AWARE. ReviewListItem expects product data that is equivalent to what is
206-
* made avaialble for output in a public view. Thus content that may contain
206+
* made available for output in a public view. Thus content that may contain
207207
* html data is not sanitized further.
208208
*
209209
* Currently the following data is trusted (assumed to already be sanitized):
210-
* - `review.review` (review content).
210+
* - `review.review` (review content)
211211
* - `review.product_name` (the product title)
212212
*/
213213
export default ReviewListItem;
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
/**
2-
* External dependencies
2+
* Internal dependencies
33
*/
4-
import { render } from 'react-dom';
4+
import renderFrontend from '../../utils/render-frontend.js';
55

66
/**
77
* Internal dependencies
88
*/
99
import Block from './block.js';
1010

11-
const containers = document.querySelectorAll(
12-
'.wp-block-woocommerce-price-filter'
13-
);
14-
15-
if ( containers.length ) {
16-
Array.prototype.forEach.call( containers, ( el ) => {
17-
const attributes = {
11+
const getProps = ( el ) => {
12+
return {
13+
attributes: {
1814
showInputFields: el.dataset.showinputfields === 'true',
1915
showFilterButton: el.dataset.showfilterbutton === 'true',
20-
};
21-
el.classList.remove( 'is-loading' );
16+
},
17+
};
18+
};
2219

23-
render( <Block attributes={ attributes } />, el );
24-
} );
25-
}
20+
renderFrontend( '.wp-block-woocommerce-price-filter', Block, getProps );

assets/js/data/collections/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ This selector will return the collection for the given arguments. It has a sibli
3636
| `query` | Object | The query arguments for the collection. Eg. `{ order: 'ASC', sortBy: Price }` |
3737
| `ids` | Array | If the collection route has placeholders for ids you provide the values for those placeholders in this array (in order). |
3838

39-
### `getCollectionHeader( namespace, modelName, header, query = null, ids = [])
39+
### `getCollectionHeader( namespace, modelName, header, query = null, ids = [])`
4040

4141
This selector will return a header from the collection response using the given arguments. It has a sibling resolver that will resolve `getCollection` using the arguments if that has never been resolved.
4242

assets/js/data/collections/selectors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const getCollectionHeader = (
108108
);
109109
// Can't just do a truthy check because `getCollectionHeaders` resolver
110110
// invokes the `getCollection` selector to trigger the resolution of the
111-
// collection request. It's fallback is an empty array.
111+
// collection request. Its fallback is an empty array.
112112
if ( headers && headers.get ) {
113113
return headers.has( header ) ? headers.get( header ) : undefined;
114114
}

0 commit comments

Comments
 (0)