mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 20:08:13 +00:00
LibWeb: Add getElementsByTagNameNS and add support for * in non-NS
This also moves getElementsByTagName to ParentNode to remove the code duplication between Document and Element. This additionally fixes a bug where getElementsByTagName did not check if the element was a descendant, meaning it would also include the context element if the condition matched.
This commit is contained in:
parent
5c7dca3526
commit
d47e431d54
8 changed files with 70 additions and 24 deletions
|
@ -511,17 +511,6 @@ NonnullRefPtr<HTMLCollection> Document::get_elements_by_name(String const& name)
|
|||
});
|
||||
}
|
||||
|
||||
NonnullRefPtr<HTMLCollection> Document::get_elements_by_tag_name(FlyString const& tag_name)
|
||||
{
|
||||
// FIXME: Support "*" for tag_name
|
||||
// https://dom.spec.whatwg.org/#concept-getelementsbytagname
|
||||
return HTMLCollection::create(*this, [tag_name](Element const& element) {
|
||||
if (element.namespace_() == Namespace::HTML)
|
||||
return element.local_name().to_lowercase() == tag_name.to_lowercase();
|
||||
return element.local_name() == tag_name;
|
||||
});
|
||||
}
|
||||
|
||||
NonnullRefPtr<HTMLCollection> Document::get_elements_by_class_name(FlyString const& class_name)
|
||||
{
|
||||
return HTMLCollection::create(*this, [class_name, quirks_mode = document().in_quirks_mode()](Element const& element) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue