Skip to content

Commit

Permalink
vaev-style: Fix not selectors, parsing everything in the parenthesis.
Browse files Browse the repository at this point in the history
  • Loading branch information
Louciole committed Jan 29, 2025
1 parent 7774628 commit 34c4041
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/web/vaev-style/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ static Res<Selector> _parseSelectorElement(Cursor<Css::Sst>& cur, OpCode current

if (cur->prefix == Css::Token::function("not(")) {
Cursor<Css::Sst> c = cur->content;
val = Selector::not_(try$(_parseSelectorElement(c, OpCode::NOT)));
// consume a whole selector not a single one
val = Selector::not_(try$(Selector::parse(c)));
} else {
val = Pseudo::make(cur->token.data);
}
Expand Down
16 changes: 16 additions & 0 deletions src/web/vaev-style/tests/test-parse-selectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,22 @@ test$("vaev-style-parse-pseudo-selectors") {
})
);

expectEq$(
try$(Selector::parse("div::not(.foo)")),
Selector::and_({
TypeSelector{Html::DIV},
Selector::not_(ClassSelector{"foo"s})
})
);

expectEq$(
try$(Selector::parse("div::not(.foo, .bar)")),
Selector::and_({
TypeSelector{Html::DIV},
Selector::not_(Selector::or_({ClassSelector{"foo"s},ClassSelector{"bar"s}}))
})
);

return Ok();
}

Expand Down

0 comments on commit 34c4041

Please sign in to comment.