mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00
LibWeb: Add FlyString versions of NamedNodeMap::get_attribute_ns
This is the API for NamedNodeMap which we are wanting to eventually use instead of taking a StringView. Currently we just end up deferring to the StringView versions of these functions, but at some stage in the future, this will allow us to have O(1) comparison when making attribute lookups. In the meantime, the advantage of this API is that it makes it much less awkward to use than the StringView variant when you have an Optional<FlyString> namespace to pass through.
This commit is contained in:
parent
49dbc4b5a5
commit
1812221a2d
2 changed files with 20 additions and 0 deletions
|
@ -176,6 +176,23 @@ Attr const* NamedNodeMap::get_attribute(StringView qualified_name, size_t* item_
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
|
||||
Attr const* NamedNodeMap::get_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& local_name, size_t* item_index) const
|
||||
{
|
||||
// FIXME: We shouldn't need to do any conversion when looking up in the node map.
|
||||
StringView namespace_view;
|
||||
if (namespace_.has_value())
|
||||
namespace_view = namespace_->bytes_as_string_view();
|
||||
|
||||
return get_attribute_ns(namespace_view, local_name, item_index);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
|
||||
Attr* NamedNodeMap::get_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& local_name, size_t* item_index)
|
||||
{
|
||||
return const_cast<Attr*>(const_cast<NamedNodeMap const*>(this)->get_attribute_ns(namespace_, local_name, item_index));
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
|
||||
Attr* NamedNodeMap::get_attribute_ns(StringView namespace_, StringView local_name, size_t* item_index)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue