Editor: fix fluid font division by zero error when min and max viewport widths are equal.

Fixes a division error by returning null when `minViewportWidth` - `maxViewportWidth` is zero in `wp_get_computed_fluid_typography_value`.

Props ramonopoly, mukesh27, andrewserong, audrasjb.
Fixes #60263.


git-svn-id: https://develop.svn.wordpress.org/trunk@57329 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Isabel Brison
2024-01-23 05:55:49 +00:00
parent c9f04d4053
commit ba4271374d
2 changed files with 19 additions and 1 deletions

View File

@@ -913,6 +913,7 @@ class Tests_Block_Supports_Typography extends WP_UnitTestCase {
* Tests computed font size values.
*
* @ticket 58522
* @ticket 60263
*
* @covers ::wp_get_computed_fluid_typography_value
*
@@ -951,6 +952,16 @@ class Tests_Block_Supports_Typography extends WP_UnitTestCase {
),
'expected_output' => 'clamp(50px, 3.125rem + ((1vw - 3.2px) * 7.353), 100px)',
),
'returns `null` when maximum and minimum viewport width are equal' => array(
'args' => array(
'minimum_viewport_width' => '800px',
'maximum_viewport_width' => '800px',
'minimum_font_size' => '50px',
'maximum_font_size' => '100px',
'scale_factor' => 1,
),
'expected_output' => null,
),
'returns `null` when `maximum_viewport_width` is an unsupported unit' => array(
'args' => array(
'minimum_viewport_width' => '320px',