mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-14 06:11:55 +00:00
LibWeb: Update the <textarea> shadow DOM when the value attribute is set
Otherwise, setting the value attribute after the element is added to the DOM is not visibile. The logic here was stolen from the <input> element.
This commit is contained in:
parent
2b6c00e8b9
commit
abc1be5b9e
Notes:
sideshowbarker
2024-07-17 20:33:50 +09:00
Author: https://github.com/trflynn89
Commit: abc1be5b9e
Pull-request: https://github.com/SerenityOS/serenity/pull/23586
3 changed files with 33 additions and 6 deletions
|
@ -133,7 +133,10 @@ String HTMLTextAreaElement::value() const
|
|||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-value
|
||||
void HTMLTextAreaElement::set_value(String const& value)
|
||||
{
|
||||
// FIXME: 1. Let oldAPIValue be this element's API value.
|
||||
auto& realm = this->realm();
|
||||
|
||||
// 1. Let oldAPIValue be this element's API value.
|
||||
auto old_api_value = api_value();
|
||||
|
||||
// 2. Set this element's raw value to the new value.
|
||||
set_raw_value(value);
|
||||
|
@ -141,8 +144,17 @@ void HTMLTextAreaElement::set_value(String const& value)
|
|||
// 3. Set this element's dirty value flag to true.
|
||||
m_dirty_value = true;
|
||||
|
||||
// FIXME: 4. If the new API value is different from oldAPIValue, then move the text entry cursor position to the end of the text control, unselecting any selected text and resetting the selection direction to "none".
|
||||
update_placeholder_visibility();
|
||||
// 4. If the new API value is different from oldAPIValue, then move the text entry cursor position to the end of
|
||||
// the text control, unselecting any selected text and resetting the selection direction to "none".
|
||||
if (api_value() != old_api_value) {
|
||||
if (m_text_node) {
|
||||
m_text_node->set_data(m_raw_value);
|
||||
update_placeholder_visibility();
|
||||
|
||||
if (auto* browsing_context = document().browsing_context())
|
||||
browsing_context->set_cursor_position(DOM::Position::create(realm, *m_text_node, m_text_node->data().bytes().size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLTextAreaElement::set_raw_value(String value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue