Repository navigation
Sanitize the value of an input in :placeholder-shown - #363
facelessuser merged 4 commits into
Conversation
An input with a value that sanitizes to the empty string shows its placeholder: line breaks are removed from text-like values, url and email values are trimmed, and a number that is not a valid floating-point number is emptied. Chrome, Firefox and Safari all match these inputs.
|
I'm being a bit more strict about a lot of these spec fixes to try and make sure I'm not just getting another one in the same area a few days later, tweaking something that previous fixes missed. This is a review of the current changes. I checked the 12 cases in this PR's test, plus 41 more, against For context, the convention for these form-state pseudo-classes is in 1. A
|
All browsers drop such a value, so use Inputs.parse_value(), as :in-range does. Document where this follows the browsers instead of the spec, and where Firefox differs.
|
Thanks for checking it against all three browsers. Both points are done:
The changelog entry mentions the overflow case. |
|
You mention you checked 1e308 and -.5e2 as controls that still hide the placeholder. -.5e2 is already in the test, but 1e308 isn’t. Adding it would test the edge of the overflow cut-off. Can you add that? |
|
Done: |
|
Please add |
|
@gir-bot lgtm |
<input type="number" placeholder="p" value="abc">shows its placeholder: the value is not a valid floating-point number, so sanitization empties it. Chrome, Firefox and Safari all match it with:placeholder-shown; Soup Sieve doesn't, because it only checks thatvalueis missing or empty.match_placeholder_shown()now applies the value sanitization algorithm (https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm) and matches when the result is empty: text-like types drop line breaks,urlandemailalso drop leading and trailing whitespace, andnumberempties a value that is not a valid floating-point number. Theinputandtextareaalternatives are now in one:is(), so the flag applies to both, as inRANGE_INPUT.I checked 23 type/value cases in Chromium, Firefox and WebKit with Playwright. They agree on all but
value="1."fornumber, where Firefox keeps the value; the spec agrees with Chrome and Safari.test_placeholder_shown_sanitized_valuefails without the change.