LibWeb/HTML: Provide a fallback for validation anchor

Corresponds to daa3016b40

Also import a related test.
This commit is contained in:
Sam Atkins 2025-07-08 16:30:19 +01:00 committed by Tim Ledbetter
parent da8a29376f
commit 4e854ca44a
Notes: github-actions[bot] 2025-07-08 16:10:38 +00:00
3 changed files with 385 additions and 6 deletions

View file

@ -108,15 +108,17 @@ WebIDL::ExceptionOr<void> ElementInternals::set_validity(ValidityStateFlags cons
// FIXME: 6. If element's customError validity flag is true, then set element's custom validity error message to element's validation message. Otherwise, set element's custom validity error message to the empty string.
// FIXME: 7. Set element's validation anchor to null if anchor is not given. Otherwise, if anchor is not a shadow-including descendant of element, then throw a "NotFoundError" DOMException. Otherwise, set element's validation anchor to anchor.
// 7. If anchor is not given, then set it to element.
if (!anchor.has_value() || !anchor.value().ptr()) {
// FIXME
} else if (!anchor.value()->is_shadow_including_descendant_of(element)) {
return WebIDL::NotFoundError::create(realm(), "Anchor is not a shadow-including descendant of element"_string);
} else {
// FIXME
anchor = element;
}
// 8. Otherwise, if anchor is not a shadow-including inclusive descendant of element, then throw a "NotFoundError" DOMException.
else if (!anchor.value()->is_shadow_including_inclusive_descendant_of(element)) {
return WebIDL::NotFoundError::create(realm(), "Anchor is not a shadow-including descendant of element"_string);
}
// FIXME: 9. Set element's validation anchor to anchor.
dbgln("FIXME: ElementInternals::set_validity()");
return {};
}