LibWeb: Add String variants of get_element_by_{} in ParentNode

These are required for porting over Document from DeprecatedString to
String. We unfortunately can't port this completely over yet as
ParentNode is included by the Element IDL interface, which has not yet
been ported over from DeprecatedString.
This commit is contained in:
Shannon Booth 2023-09-15 21:42:32 +12:00 committed by Andreas Kling
parent 81f5b3e66d
commit 9d88e14f20
Notes: sideshowbarker 2024-07-17 03:00:02 +09:00
2 changed files with 16 additions and 0 deletions

View file

@ -120,6 +120,19 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::children()
return *m_children;
}
JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name(FlyString const& qualified_name)
{
return get_elements_by_tag_name(qualified_name.to_deprecated_fly_string());
}
JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name_ns(Optional<String> const& nullable_namespace, FlyString const& local_name)
{
DeprecatedFlyString deprecated_nullable_namespace;
if (nullable_namespace.has_value())
deprecated_nullable_namespace = nullable_namespace->to_deprecated_string();
return get_elements_by_tag_name_ns(deprecated_nullable_namespace, local_name.to_deprecated_fly_string());
}
// https://dom.spec.whatwg.org/#concept-getelementsbytagname
// NOTE: This method is only exposed on Document and Element, but is in ParentNode to prevent code duplication.
JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name(DeprecatedFlyString const& qualified_name)

View file

@ -28,6 +28,9 @@ public:
JS::NonnullGCPtr<HTMLCollection> children();
JS::NonnullGCPtr<HTMLCollection> get_elements_by_tag_name(FlyString const&);
JS::NonnullGCPtr<HTMLCollection> get_elements_by_tag_name_ns(Optional<String> const&, FlyString const&);
JS::NonnullGCPtr<HTMLCollection> get_elements_by_tag_name(DeprecatedFlyString const&);
JS::NonnullGCPtr<HTMLCollection> get_elements_by_tag_name_ns(DeprecatedFlyString const&, DeprecatedFlyString const&);