Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5958b2c58e6a3bc0fe998a100be1e03d8d7e75bb
https://github.com/WebKit/WebKit/commit/5958b2c58e6a3bc0fe998a100be1e03d8d7e75bb
Author: Ahmad Saleem <[email protected]>
Date: 2026-07-14 (Tue, 14 Jul 2026)
Changed paths:
M LayoutTests/inspector/model/boxShadow-expected.txt
M LayoutTests/inspector/model/boxShadow.html
M Source/WebInspectorUI/UserInterface/Models/BoxShadow.js
Log Message:
-----------
Web Inspector: BoxShadow fails to parse valid lengths like "1.50px", "1e2px",
and uppercase units
https://bugs.webkit.org/show_bug.cgi?id=319362
rdar://182169640
Reviewed by Devin Rousso.
WI.BoxShadow.parseNumberComponent() split a length component into value and
unit by calling `string.replace(value, "")`, passing the parsed Number as the
search argument. String.prototype.replace coerces that Number to a string via
String(value) and removes only the first literal occurrence, so it only worked
when String(parseFloat(s)) reproduced the exact numeric prefix of the source
text. It did not for several valid CSS length forms:
- "1.50px": String(1.5) is "1.5", so "1.5" was stripped leaving "0px", which
is not a valid unit, so the whole box-shadow failed to parse.
- "1e2px": String(100) is "100", which is not a substring of "1e2px", so the
number was left in place leaving unit "1e2px".
- ".5px": String(0.5) is "0.5", which is not a substring of ".5px".
Strip the leading number positionally with a regular expression instead, so the
remaining text is always the unit regardless of how the number is spelled. The
exponent group requires a trailing digit, so units that begin with "e" (em, ex)
are preserved rather than mistaken for scientific notation.
While here, also fix two related issues at the same time:
- Non-finite values: a literal that overflows to Infinity (e.g. "1e400px")
passed the previous isNaN() guard and, with the regex now yielding a valid
"px" unit, would serialize as "Infinitypx". Guard with isFinite() so NaN,
Infinity, and -Infinity are all rejected.
- Case-insensitive units: CSS units are case-insensitive, but the unit was
matched against a lowercase Set, so "1PX" was rejected. Lowercase the unit
before the membership check, which also canonicalizes serialization.
* LayoutTests/inspector/model/boxShadow-expected.txt:
* LayoutTests/inspector/model/boxShadow.html:
* Source/WebInspectorUI/UserInterface/Models/BoxShadow.js:
(WI.BoxShadow.parseNumberComponent):
Canonical link: https://commits.webkit.org/317161@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications