Skip to content

Commit

Permalink
Handle NaN font sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmx-dev committed Dec 18, 2024
1 parent 4126f3c commit 85f30c9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/checkout/upe-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,10 @@ function ensureFontSizeSmallerThan(
) {
const fontSizeNumber = parseFloat( fontSize );

if ( isNaN( fontSizeNumber ) ) {
return fontSize;
}

// If the element is not found, return the font size number multiplied by the percentage.
const elem = document.querySelector( selector );
if ( ! elem ) {
Expand All @@ -505,6 +509,10 @@ function ensureFontSizeSmallerThan(
const targetFontSize = styles.getPropertyValue( 'font-size' );
const targetFontSizeNumber = parseFloat( targetFontSize ) * percentage;

if ( isNaN( targetFontSizeNumber ) ) {
return fontSize;
}

if ( fontSizeNumber > targetFontSizeNumber ) {
return `${ targetFontSizeNumber }px`;
}
Expand Down

0 comments on commit 85f30c9

Please sign in to comment.