mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 18:35:07 +00:00
LibWeb: Add naive support for document.querySelectorAll()
This currently returns a JS::Array of elements matching a selector. The more correct behavior would be to return a static NodeList, but as we don't have NodeLists right now, that'll be a task for the future.
This commit is contained in:
parent
c56acba75e
commit
0f7bcd4111
11 changed files with 182 additions and 78 deletions
|
@ -267,6 +267,9 @@ public:
|
|||
|
||||
Optional<Selector::SimpleSelector> parse_simple_selector()
|
||||
{
|
||||
if (!peek())
|
||||
return {};
|
||||
|
||||
if (consume_whitespace_or_comments())
|
||||
return {};
|
||||
|
||||
|
@ -658,6 +661,16 @@ private:
|
|||
StringView css;
|
||||
};
|
||||
|
||||
Optional<Selector> parse_selector(const StringView& selector_text)
|
||||
{
|
||||
CSSParser parser(selector_text);
|
||||
auto complex_selector = parser.parse_complex_selector();
|
||||
if (!complex_selector.has_value())
|
||||
return {};
|
||||
complex_selector.value().relation = Selector::ComplexSelector::Relation::None;
|
||||
return Selector({ complex_selector.value() });
|
||||
}
|
||||
|
||||
RefPtr<StyleSheet> parse_css(const StringView& css)
|
||||
{
|
||||
CSSParser parser(css);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue