mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
LibWeb: Handle radio/checkbox default-or-on value attribute state
If the value attribute is missing, these input elements should be returning 'on' as their value in their IDL.
This commit is contained in:
parent
fc4fd6cb02
commit
0f374afc8f
1 changed files with 7 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||||
* Copyright (c) 2022, Adam Hodgen <ant1441@gmail.com>
|
* Copyright (c) 2022, Adam Hodgen <ant1441@gmail.com>
|
||||||
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
|
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
|
||||||
|
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -310,6 +311,12 @@ DeprecatedString HTMLInputElement::value() const
|
||||||
return DeprecatedString::empty();
|
return DeprecatedString::empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
|
||||||
|
if (type_state() == TypeAttributeState::Checkbox || type_state() == TypeAttributeState::RadioButton) {
|
||||||
|
// On getting, if the element has a value content attribute, return that attribute's value; otherwise, return the string "on".
|
||||||
|
return has_attribute(AttributeNames::value) ? get_attribute(AttributeNames::value) : "on";
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-value
|
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-value
|
||||||
// Return the current value of the element.
|
// Return the current value of the element.
|
||||||
return m_value;
|
return m_value;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue