Skip to content

Commit 673527d

Browse files
linusgawesomekling
authored andcommitted
LibWeb: Ignore parsed pseudo-element selectors & empty complex selectors
Currently we don't deal with them, so they shouldn't return a SimpleSelector - that'd be a false positive. Also don't produce a ComplexSelector if no SimpleSelector was parsed. This fixes a couple of rendering issues on awesomekling.github.io: link colours, footer size, content max-width (and possibly more!)
1 parent a427821 commit 673527d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Libraries/LibWeb/Parser/CSSParser.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@ class CSSParser {
383383
auto pseudo_name = String::copy(buffer);
384384
buffer.clear();
385385

386+
387+
// Ignore for now, otherwise we produce a "false positive" selector
388+
// and apply styles to the element itself, not its pseudo element
389+
if (is_pseudo_element)
390+
return {};
391+
386392
if (pseudo_name == "link")
387393
simple_selector.pseudo_class = Selector::SimpleSelector::PseudoClass::Link;
388394
else if (pseudo_name == "hover")
@@ -442,6 +448,9 @@ class CSSParser {
442448
PARSE_ASSERT(simple_selectors.size() < 100);
443449
}
444450

451+
if (simple_selectors.is_empty())
452+
return {};
453+
445454
return Selector::ComplexSelector { relation, move(simple_selectors) };
446455
}
447456

0 commit comments

Comments
 (0)