|
@@ -14,6 +14,7 @@
|
|
|
#include <LibWeb/DOM/ParentNode.h>
|
|
|
#include <LibWeb/DOM/StaticNodeList.h>
|
|
|
#include <LibWeb/Dump.h>
|
|
|
+#include <LibWeb/Infra/CharacterTypes.h>
|
|
|
#include <LibWeb/Infra/Strings.h>
|
|
|
#include <LibWeb/Namespace.h>
|
|
|
|
|
@@ -225,4 +226,19 @@ WebIDL::ExceptionOr<void> ParentNode::replace_children(Vector<Variant<JS::Handle
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
+JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_class_name(StringView class_names)
|
|
|
+{
|
|
|
+ Vector<FlyString> list_of_class_names;
|
|
|
+ for (auto& name : class_names.split_view_if(Infra::is_ascii_whitespace)) {
|
|
|
+ list_of_class_names.append(FlyString::from_utf8(name).release_value_but_fixme_should_propagate_errors());
|
|
|
+ }
|
|
|
+ return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [list_of_class_names = move(list_of_class_names), quirks_mode = document().in_quirks_mode()](Element const& element) {
|
|
|
+ for (auto& name : list_of_class_names) {
|
|
|
+ if (!element.has_class(name, quirks_mode ? CaseSensitivity::CaseInsensitive : CaseSensitivity::CaseSensitive))
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
}
|