mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
LibWeb: Implement HTMLInputElement type=url constraint validation
This change implements HTMLInputElement type=url constraint validation in such a way as to match the behavior in other existing engines (which is, however, very different from what the spec currently requires).
This commit is contained in:
parent
6606eecce5
commit
38197916c3
Notes:
github-actions[bot]
2025-03-04 19:16:38 +00:00
Author: https://github.com/sideshowbarker
Commit: 38197916c3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3743
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 13 additions and 9 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <LibJS/Runtime/Date.h>
|
||||
#include <LibJS/Runtime/NativeFunction.h>
|
||||
#include <LibJS/Runtime/RegExpObject.h>
|
||||
#include <LibURL/Parser.h>
|
||||
#include <LibWeb/Bindings/HTMLInputElementPrototype.h>
|
||||
#include <LibWeb/Bindings/PrincipalHostDefined.h>
|
||||
#include <LibWeb/CSS/ComputedProperties.h>
|
||||
|
@ -3044,12 +3045,15 @@ bool HTMLInputElement::suffering_from_being_missing() const
|
|||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-type-mismatch
|
||||
bool HTMLInputElement::suffering_from_a_type_mismatch() const
|
||||
{
|
||||
auto input = value();
|
||||
switch (type_state()) {
|
||||
case TypeAttributeState::URL:
|
||||
// https://html.spec.whatwg.org/multipage/input.html#url-state-(type%3Durl)%3Asuffering-from-a-type-mismatch
|
||||
// While the value of the element is neither the empty string nor a valid absolute URL, the element is suffering from a type mismatch.
|
||||
// FIXME: Implement this.
|
||||
break;
|
||||
// AD-HOC: https://github.com/whatwg/html/issues/11083 and https://github.com/web-platform-tests/wpt/pull/51011
|
||||
// We intentionally don't check if the value is a "valid absolute URL", because that's not what other
|
||||
// engines actually do. So we instead just implement what matches the behavior in existing engines.
|
||||
return !input.is_empty() && !URL::Parser::basic_parse(input).has_value();
|
||||
case TypeAttributeState::Email:
|
||||
// https://html.spec.whatwg.org/multipage/input.html#email-state-(type%3Demail)%3Asuffering-from-a-type-mismatch
|
||||
// While the value of the element is neither the empty string nor a single valid email address, the element is suffering from a type mismatch.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue