♻️ Make code more readable, resolve one warning

This commit is contained in:
Philipp Stracker 2025-03-18 14:53:49 +01:00
parent 122be6dcd7
commit b5c08e842e
No known key found for this signature in database
2 changed files with 8 additions and 5 deletions

View file

@ -214,7 +214,9 @@ class Renderer {
} }
); );
this.renderedSources.add( wrapper + ( fundingSource ?? '' ) ); this.renderedSources.add(
wrapper + ( fundingSource ? fundingSource : '' )
);
if ( window.paypal?.Buttons ) { if ( window.paypal?.Buttons ) {
widgetBuilder.registerButtons( widgetBuilder.registerButtons(

View file

@ -40,8 +40,9 @@ class WidgetBuilder {
renderButtons( wrapper ) { renderButtons( wrapper ) {
wrapper = this.sanitizeWrapper( wrapper ); wrapper = this.sanitizeWrapper( wrapper );
const entryKey = this.toKey( wrapper );
if ( ! this.buttons.has( this.toKey( wrapper ) ) ) { if ( ! this.buttons.has( entryKey ) ) {
return; return;
} }
@ -49,11 +50,11 @@ class WidgetBuilder {
return; return;
} }
const entry = this.buttons.get( this.toKey( wrapper ) ); const entry = this.buttons.get( entryKey );
const btn = this.paypal.Buttons( entry.options ); const btn = this.paypal.Buttons( entry.options );
if ( ! btn.isEligible() ) { if ( ! btn.isEligible() ) {
this.buttons.delete( this.toKey( wrapper ) ); this.buttons.delete( entryKey );
return; return;
} }
@ -67,7 +68,7 @@ class WidgetBuilder {
} }
renderAllButtons() { renderAllButtons() {
for ( const [ wrapper, entry ] of this.buttons ) { for ( const [ wrapper ] of this.buttons ) {
this.renderButtons( wrapper ); this.renderButtons( wrapper );
} }
} }