mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-03 17:02:56 +00:00
LibWeb: Follow the specification steps to serialize a DOMTokenList
This ensures that calling `element.classList.toString()` always produces the correct value.
This commit is contained in:
parent
21e21abeed
commit
ec1f7779cb
Notes:
github-actions[bot]
2024-07-25 04:44:28 +00:00
Author: https://github.com/tcl3
Commit: ec1f7779cb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/817
4 changed files with 17 additions and 3 deletions
|
@ -239,14 +239,20 @@ WebIDL::ExceptionOr<bool> DOMTokenList::supports(StringView token)
|
|||
return false;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-value
|
||||
String DOMTokenList::value() const
|
||||
// https://dom.spec.whatwg.org/#concept-ordered-set-serializer
|
||||
String DOMTokenList::serialize_ordered_set() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.join(' ', m_token_set);
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-value
|
||||
String DOMTokenList::value() const
|
||||
{
|
||||
return m_associated_element->get_attribute_value(m_associated_attribute);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#ref-for-concept-element-attributes-set-value%E2%91%A2
|
||||
void DOMTokenList::set_value(String const& value)
|
||||
{
|
||||
|
@ -278,7 +284,7 @@ void DOMTokenList::run_update_steps()
|
|||
return;
|
||||
|
||||
// 2. Set an attribute value for the associated element using associated attribute’s local name and the result of running the ordered set serializer for token set.
|
||||
MUST(associated_element->set_attribute(m_associated_attribute, value()));
|
||||
MUST(associated_element->set_attribute(m_associated_attribute, serialize_ordered_set()));
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> DOMTokenList::item_value(size_t index) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue