Add shouldRender method for the context bootstrappers

This commit is contained in:
Mészáros Róbert 2020-04-09 10:49:37 +03:00
parent 9f1a633ad9
commit 5990d9766b
4 changed files with 34 additions and 27 deletions

View file

@ -6,13 +6,11 @@ class MiniCartBootstap {
}
init() {
const miniCartWrapper = PayPalCommerceGateway.button.mini_cart_wrapper;
if (!document.querySelector(miniCartWrapper)) {
if (!this.shouldRender()) {
return;
}
const renderer = new Renderer(miniCartWrapper);
const renderer = new Renderer(PayPalCommerceGateway.button.mini_cart_wrapper);
jQuery(document.body).
on('wc_fragments_loaded wc_fragments_refreshed', () => {
@ -21,6 +19,10 @@ class MiniCartBootstap {
renderer.render(this.configurator.configuration());
}
shouldRender() {
return document.querySelector(PayPalCommerceGateway.button.mini_cart_wrapper)
}
}
export default MiniCartBootstap;