Skip to content

Commit

Permalink
fix: add resource load-once capability (#19859)
Browse files Browse the repository at this point in the history
CXSPA-8883

Option to load css and js files only once rather than deleted and re-adding at each payment/page changes.
This option is toggled on OPF server server side by adding 'opf-load-once'='true' attribute to resource file.
  • Loading branch information
FollowTheFlo authored Jan 14, 2025
1 parent 125c6a9 commit e7b7e65
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ export class OpfResourceLoaderService {
keyValueList?.forEach((keyValue: OpfKeyValueMap) => {
attributes[keyValue.key] = keyValue.value;
});
if (attributes?.[this.OPF_RESOURCE_LOAD_ONCE_ATTRIBUTE_KEY] === 'true') {
if (
!attributes?.[this.OPF_RESOURCE_LOAD_ONCE_ATTRIBUTE_KEY] ||
attributes[this.OPF_RESOURCE_LOAD_ONCE_ATTRIBUTE_KEY] !== 'true'
) {
attributes[this.OPF_RESOURCE_ATTRIBUTE_KEY] = 'true';
}
delete attributes?.[this.OPF_RESOURCE_LOAD_ONCE_ATTRIBUTE_KEY];
Expand Down

0 comments on commit e7b7e65

Please sign in to comment.