mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-06 05:24:17 +00:00
LibHTML: Handle stand-alone attribute selectors
A selector like "[foo]" is now parsed as a universal selector component with an attribute match type. Pretty neat :^)
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
<head>
|
||||
<title>CSS attribute selector test</title>
|
||||
<style type="text/css">
|
||||
[hello=friends] {
|
||||
background-color: #f0f;
|
||||
color: white;
|
||||
}
|
||||
div[id="foo"] {
|
||||
background-color: blue;
|
||||
color: #fff;
|
||||
@@ -13,6 +17,7 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div hello=friends>This div is hello, friends!</div>
|
||||
<div id="foo">This div has id="foo" and is bloo!</div>
|
||||
<div cool="">This div has a "cool" attribute and a cool green color.</div>
|
||||
</body>
|
||||
|
||||
@@ -244,14 +244,18 @@ public:
|
||||
} else if (peek() == '#') {
|
||||
type = Selector::Component::Type::Id;
|
||||
consume_one();
|
||||
} else {
|
||||
} else if (isalpha(peek())) {
|
||||
type = Selector::Component::Type::TagName;
|
||||
} else {
|
||||
type = Selector::Component::Type::Universal;
|
||||
}
|
||||
|
||||
while (is_valid_selector_char(peek()))
|
||||
buffer.append(consume_one());
|
||||
if (type != Selector::Component::Type::Universal) {
|
||||
while (is_valid_selector_char(peek()))
|
||||
buffer.append(consume_one());
|
||||
PARSE_ASSERT(!buffer.is_null());
|
||||
}
|
||||
|
||||
PARSE_ASSERT(!buffer.is_null());
|
||||
Selector::Component component {
|
||||
type,
|
||||
Selector::Component::PseudoClass::None,
|
||||
|
||||
Reference in New Issue
Block a user