mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibWeb: Port Element::get_attribute_value from ByteString
This commit is contained in:
parent
2751f32a18
commit
462f97b28a
Notes:
sideshowbarker
2024-07-16 22:14:49 +09:00
Author: https://github.com/shannonbooth
Commit: 462f97b28a
Pull-request: https://github.com/SerenityOS/serenity/pull/22452
3 changed files with 9 additions and 8 deletions
|
@ -130,17 +130,17 @@ ByteString Element::deprecated_get_attribute(StringView name) const
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-value
|
||||
ByteString Element::get_attribute_value(FlyString const& local_name, Optional<FlyString> const& namespace_) const
|
||||
String Element::get_attribute_value(FlyString const& local_name, Optional<FlyString> const& namespace_) const
|
||||
{
|
||||
// 1. Let attr be the result of getting an attribute given namespace, localName, and element.
|
||||
auto const* attribute = m_attributes->get_attribute_ns(namespace_, local_name);
|
||||
|
||||
// 2. If attr is null, then return the empty string.
|
||||
if (!attribute)
|
||||
return ByteString::empty();
|
||||
return String {};
|
||||
|
||||
// 3. Return attr’s value.
|
||||
return attribute->value().to_byte_string();
|
||||
return attribute->value();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-getattributenode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue