mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb: Follow spec steps to set the selectionDirection attribute value
This commit is contained in:
parent
e0cd2edccb
commit
d0b97873d4
Notes:
github-actions[bot]
2024-10-04 17:43:25 +00:00
Author: https://github.com/tcl3
Commit: d0b97873d4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1625
10 changed files with 68 additions and 4 deletions
|
@ -366,6 +366,22 @@ void FormAssociatedTextControlElement::set_selection_direction(Optional<String>
|
|||
m_selection_direction = string_to_selection_direction(direction);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-selectiondirection
|
||||
WebIDL::ExceptionOr<void> FormAssociatedTextControlElement::set_selection_direction_binding(Optional<String> direction)
|
||||
{
|
||||
// 1. If this element is an input element, and selectionDirection does not apply to this element,
|
||||
// throw an "InvalidStateError" DOMException.
|
||||
auto const& html_element = form_associated_element_to_html_element();
|
||||
if (is<HTMLInputElement>(html_element)) {
|
||||
auto const& input_element = static_cast<HTMLInputElement const&>(html_element);
|
||||
if (!input_element.selection_direction_applies())
|
||||
return WebIDL::InvalidStateError::create(input_element.realm(), "selectionDirection does not apply to element"_fly_string);
|
||||
}
|
||||
|
||||
set_the_selection_range(m_selection_start, m_selection_end, string_to_selection_direction(direction));
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-setrangetext
|
||||
WebIDL::ExceptionOr<void> FormAssociatedTextControlElement::set_range_text(String const& replacement)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue