1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:27:45 +00:00

LibWeb: Make Element::has_attribute take a StringView

It calls Element::get_attribute which takes a StringView. Ultimately,
this should be taking a FlyString, but to help in porting away from
DeprecatedString, just leave a FIXME for that for now.
This commit is contained in:
Shannon Booth 2023-09-21 20:26:19 +12:00 committed by Andreas Kling
parent 52fccae654
commit 79f97da4b4
5 changed files with 8 additions and 5 deletions

View file

@ -302,7 +302,7 @@ void Element::remove_attribute(StringView name)
}
// https://dom.spec.whatwg.org/#dom-element-hasattribute
bool Element::has_attribute(DeprecatedFlyString const& name) const
bool Element::has_attribute(StringView name) const
{
return m_attributes->get_attribute(name) != nullptr;
}

View file

@ -91,7 +91,8 @@ public:
// NOTE: This is for the JS bindings
DeprecatedFlyString namespace_uri() const { return namespace_(); }
bool has_attribute(DeprecatedFlyString const& name) const;
// FIXME: This should be taking a 'FlyString const&'
bool has_attribute(StringView name) const;
bool has_attribute_ns(DeprecatedFlyString namespace_, DeprecatedFlyString const& name) const;
bool has_attributes() const;
@ -104,6 +105,7 @@ public:
return String::from_deprecated_string(ret).release_value();
}
// FIXME: This should be taking a 'FlyString const&' / 'Optional<FlyString> const&'
DeprecatedString get_attribute(DeprecatedFlyString const& name) const;
DeprecatedString get_attribute_value(DeprecatedFlyString const& local_name, DeprecatedFlyString const& namespace_ = {}) const;

View file

@ -43,6 +43,7 @@ public:
WebIDL::ExceptionOr<Attr const*> remove_named_item_ns(Optional<String> const& namespace_, StringView local_name);
// Methods defined by the spec for internal use:
// FIXME: These should be taking `FlyString const&' / 'Optional<FlyString> const&'
Attr* get_attribute(StringView qualified_name, size_t* item_index = nullptr);
Attr* get_attribute_ns(StringView namespace_, StringView local_name, size_t* item_index = nullptr);
Attr const* get_attribute(StringView qualified_name, size_t* item_index = nullptr) const;