diff --git a/Libraries/LibHTML/CSS/Selector.h b/Libraries/LibHTML/CSS/Selector.h
index c30bad10d6..56e96a2569 100644
--- a/Libraries/LibHTML/CSS/Selector.h
+++ b/Libraries/LibHTML/CSS/Selector.h
@@ -9,6 +9,7 @@ public:
struct Component {
enum class Type {
Invalid,
+ Universal,
TagName,
Id,
Class,
diff --git a/Libraries/LibHTML/CSS/SelectorEngine.cpp b/Libraries/LibHTML/CSS/SelectorEngine.cpp
index 56ad75c050..58ef15bd01 100644
--- a/Libraries/LibHTML/CSS/SelectorEngine.cpp
+++ b/Libraries/LibHTML/CSS/SelectorEngine.cpp
@@ -30,6 +30,8 @@ bool matches(const Selector::Component& component, const Element& element)
}
switch (component.type) {
+ case Selector::Component::Type::Universal:
+ return true;
case Selector::Component::Type::Id:
return component.value == element.attribute("id");
case Selector::Component::Type::Class:
diff --git a/Libraries/LibHTML/Dump.cpp b/Libraries/LibHTML/Dump.cpp
index 424faffd84..ab17073da0 100644
--- a/Libraries/LibHTML/Dump.cpp
+++ b/Libraries/LibHTML/Dump.cpp
@@ -150,6 +150,9 @@ void dump_rule(const StyleRule& rule)
case Selector::Component::Type::Invalid:
type_description = "Invalid";
break;
+ case Selector::Component::Type::Universal:
+ type_description = "Universal";
+ break;
case Selector::Component::Type::Id:
type_description = "Id";
break;
diff --git a/Libraries/LibHTML/Parser/CSSParser.cpp b/Libraries/LibHTML/Parser/CSSParser.cpp
index f21314e7dd..36669b2c14 100644
--- a/Libraries/LibHTML/Parser/CSSParser.cpp
+++ b/Libraries/LibHTML/Parser/CSSParser.cpp
@@ -224,6 +224,12 @@ public:
consume_whitespace_or_comments();
}
+ if (peek() == '*') {
+ type = Selector::Component::Type::Universal;
+ consume_one();
+ return Selector::Component { type, Selector::Component::PseudoClass::None, relation, String() };
+ }
+
if (peek() == '.') {
type = Selector::Component::Type::Class;
consume_one();