Skip to content

Commit

Permalink
fix(checkout): fix unnecessary updates with delivery options 6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Mar 14, 2024
1 parent c677920 commit fa87c31
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import {PdkUtil, useConfig, useUtil} from '@myparcel-pdk/checkout-common';

/**
* In delivery options 5.x, checking if the element exists is enough. In 6.x, the element is always present, so we need
* to check if it has content.
*/
export const deliveryOptionsIsRendered = (): boolean => {
const config = useConfig();
const getElement = useUtil(PdkUtil.GetElement);

return !getElement(config.selectors.deliveryOptions, false);
const element = getElement(config.selectors.deliveryOptions, false);

return !element || element.innerHTML !== '';
};

0 comments on commit fa87c31

Please sign in to comment.