1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:57:34 +00:00

LibWeb: Port Element::get_attribute_value from ByteString

This commit is contained in:
Shannon Booth 2023-12-27 13:28:00 +13:00 committed by Andreas Kling
parent 2751f32a18
commit 462f97b28a
3 changed files with 9 additions and 8 deletions

View file

@ -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 attrs value.
return attribute->value().to_byte_string();
return attribute->value();
}
// https://dom.spec.whatwg.org/#dom-element-getattributenode

View file

@ -103,7 +103,7 @@ public:
// FIXME: This should be taking a 'FlyString const&' / 'Optional<FlyString> const&'
Optional<String> get_attribute(StringView name) const;
ByteString deprecated_get_attribute(StringView name) const;
ByteString get_attribute_value(FlyString const& local_name, Optional<FlyString> const& namespace_ = {}) const;
String get_attribute_value(FlyString const& local_name, Optional<FlyString> const& namespace_ = {}) const;
WebIDL::ExceptionOr<void> set_attribute(FlyString const& name, String const& value);