diff --git a/Tests/LibWeb/Text/expected/DOM/HTMLCollection-empty-string-as-property-name.txt b/Tests/LibWeb/Text/expected/DOM/HTMLCollection-empty-string-as-property-name.txt new file mode 100644 index 00000000000..223b72b3006 --- /dev/null +++ b/Tests/LibWeb/Text/expected/DOM/HTMLCollection-empty-string-as-property-name.txt @@ -0,0 +1,2 @@ + Empty string in collection: false +'haxx' in collection: true diff --git a/Tests/LibWeb/Text/input/DOM/HTMLCollection-empty-string-as-property-name.html b/Tests/LibWeb/Text/input/DOM/HTMLCollection-empty-string-as-property-name.html new file mode 100644 index 00000000000..259d4d49dd6 --- /dev/null +++ b/Tests/LibWeb/Text/input/DOM/HTMLCollection-empty-string-as-property-name.html @@ -0,0 +1,10 @@ + +
+
+ diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp index 2286f91d124..07535ea1457 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp @@ -135,7 +135,7 @@ Vector HTMLCollection::supported_property_names() const for (auto const& element : m_cached_elements) { // 1. If element has an ID which is not in result, append element’s ID to result. if (auto const& id = element->id(); id.has_value()) { - if (!result.contains_slow(id.value())) + if (!id.value().is_empty() && !result.contains_slow(id.value())) result.append(id.value()); }