Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ampersand not resolved correctly on global #532

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions packages/runtime/native/CSS.ml
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,7 @@ let resolve_selectors rules =
match prefix with
| None -> current_selector
| Some prefix ->
(* child starts with &, join them without space *)
if starts_with_ampersand current_selector then
prefix ^ remove_first_ampersand current_selector
(* child starts with dot, join them without space *)
else if contains_ampersand current_selector then
if contains_ampersand current_selector then
(* reemplazar el ampersand del current_selector, con el padre *)
replace_ampersand ~by:prefix current_selector
else if starts_with_double_dot current_selector then
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime/test/test_styles.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1045,10 +1045,11 @@ let global_with_selector =
[%global
{| html { line-height: 1.15; }
a { :hover { padding: 0; } }
.foo { & .bar & .baz { padding: 0; } }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this as a separate test case? ^^

|}];
let css = get_string_style_rules () in
assert_string css
(Printf.sprintf "html{line-height:1.15;}a{}a:hover{padding:0;}")
(Printf.sprintf "html{line-height:1.15;}a{}a:hover{padding:0;}.foo{}.foo .bar .foo .baz{padding:0;}")

let tests =
( "CSS",
Expand Down
Loading