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

Update tests for fixing unifyCompound() and unifyComplex() ordering of pseudo class/element selectors #2018

Merged
merged 7 commits into from
Sep 30, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ a {b: selector.unify(".c > .d", ".e > .f")}

<===> and_child/distinct/output.css
a {
b: .e.c > .d.f;
b: .c.e > .d.f;
}

<===>
Expand All @@ -70,7 +70,7 @@ a {b: selector.unify(".c.s1-1 > .s1-2", ".c.s2-1 > .s2-2")}

<===> and_child/overlap/output.css
a {
b: .c.s2-1.s1-1 > .s1-2.s2-2;
b: .c.s1-1.s2-1 > .s1-2.s2-2;
}

<===>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ a {b: selector.unify(".c > .d + .e", ".f .g ~ .h")}

<===> isolated/output.css
a {
b: .f .c > .g ~ .d + .e.h, .f .c > .d.g + .e.h;
b: .f .c > .g ~ .d + .e.h, .f .c > .g.d + .e.h;
}

<===>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ a {b: selector.unify(".c + .d", ".e ~ .f")}

<===> and_sibling/distinct/output.css
a {
b: .e ~ .c + .d.f, .c.e + .d.f;
b: .e ~ .c + .d.f, .e.c + .d.f;
}

<===>
Expand Down Expand Up @@ -59,7 +59,7 @@ a {b: selector.unify(".c.s1-1 + .s1-2", ".c.s2-1 ~ .s2-2")}

<===> and_sibling/overlap/output.css
a {
b: .c.s2-1 ~ .c.s1-1 + .s1-2.s2-2, .c.s1-1.s2-1 + .s1-2.s2-2;
b: .c.s2-1 ~ .c.s1-1 + .s1-2.s2-2, .c.s2-1.s1-1 + .s1-2.s2-2;
}

<===>
Expand All @@ -81,7 +81,7 @@ a {b: selector.unify(".c + .d", ".e + .f")}

<===> and_next_sibling/distinct/output.css
a {
b: .e.c + .d.f;
b: .c.e + .d.f;
}

<===>
Expand All @@ -103,7 +103,7 @@ a {b: selector.unify(".c.s1-1 + .s1-2", ".c.s2-1 + .s2-2")}

<===> and_next_sibling/overlap/output.css
a {
b: .c.s2-1.s1-1 + .s1-2.s2-2;
b: .c.s1-1.s2-1 + .s1-2.s2-2;
}

<===>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ a {b: selector.unify(".c ~ .d", ".e ~ .f")}

<===> and_sibling/distinct/output.css
a {
b: .c ~ .e ~ .d.f, .e ~ .c ~ .d.f, .e.c ~ .d.f;
b: .c ~ .e ~ .d.f, .e ~ .c ~ .d.f, .c.e ~ .d.f;
}

<===>
Expand Down Expand Up @@ -59,7 +59,7 @@ a {b: selector.unify(".c.s1-1 ~ .s1-2", ".c.s2-1 ~ .s2-2")}

<===> and_sibling/overlap/output.css
a {
b: .c.s1-1 ~ .c.s2-1 ~ .s1-2.s2-2, .c.s2-1 ~ .c.s1-1 ~ .s1-2.s2-2, .c.s2-1.s1-1 ~ .s1-2.s2-2;
b: .c.s1-1 ~ .c.s2-1 ~ .s1-2.s2-2, .c.s2-1 ~ .c.s1-1 ~ .s1-2.s2-2, .c.s1-1.s2-1 ~ .s1-2.s2-2;
}

<===>
Expand All @@ -81,7 +81,7 @@ a {b: selector.unify(".c ~ .d", ".e + .f")}

<===> and_next_sibling/distinct/output.css
a {
b: .c ~ .e + .d.f, .e.c + .d.f;
b: .c ~ .e + .d.f, .c.e + .d.f;
}

<===>
Expand Down Expand Up @@ -114,7 +114,7 @@ a {b: selector.unify(".c.s1-1 ~ .s1-2", ".c.s2-1 + .s2-2")}

<===> and_next_sibling/overlap/output.css
a {
b: .c.s1-1 ~ .c.s2-1 + .s1-2.s2-2, .c.s2-1.s1-1 + .s1-2.s2-2;
b: .c.s1-1 ~ .c.s2-1 + .s1-2.s2-2, .c.s1-1.s2-1 + .s1-2.s2-2;
}

<===>
Expand Down
4 changes: 2 additions & 2 deletions spec/core_functions/selector/unify/complex/rootish.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ a {b: selector.unify(".c:root .d", ".e:root .f")}

<===> root/in_both/can_unify/output.css
a {
b: .e.c:root .d.f;
b: .c.e:root .d.f;
}

<===>
Expand Down Expand Up @@ -121,5 +121,5 @@ a {b: selector.unify(":root .c .d", ":scope .e .f")}

<===> mixed/output.css
a {
b: :scope:root .c .e .d.f, :scope:root .e .c .d.f;
b: :root:scope .c .e .d.f, :root:scope .e .c .d.f;
}
89 changes: 87 additions & 2 deletions spec/core_functions/selector/unify/compound.hrx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,37 @@ a {

<===>
================================================================================
<===> full_overlap/input.scss
<===> full_overlap/class/input.scss
@use "sass:selector";
a {b: selector.unify(".c.d", ".c.d")}

<===> full_overlap/output.css
<===> full_overlap/class/output.css
a {
b: .c.d;
}

<===>
================================================================================
<===> full_overlap/pseudo_element/class_after/input.scss
@use "sass:selector";
a {b: selector.unify("::c.d", "::c.d")}

<===> full_overlap/pseudo_element/class_after/output.css
a {
b: ::c.d;
}

<===>
================================================================================
<===> full_overlap/pseudo/different_order/input.scss
@use "sass:selector";
a {b: selector.unify("::c.d", ".d::c")}

<===> full_overlap/pseudo/different_order/output.css
a {
b: ::c.d;
}
Goodwine marked this conversation as resolved.
Show resolved Hide resolved

<===>
================================================================================
<===> order/preserved_by_default/input.scss
Expand Down Expand Up @@ -94,3 +116,66 @@ a {b: selector.unify(":c", "::d")}
a {
b: :c::d;
}

<===>
================================================================================
<===> order/do_not_cross_pseudo_element/pseudo_class_and_element/into_simple/input.scss
@use "sass:selector";
a {b: selector.unify(".x::scrollbar:horizontal", ".y")}

<===> order/do_not_cross_pseudo_element/pseudo_class_and_element/into_simple/output.css
a {
b: .x.y::scrollbar:horizontal;
}

<===>
================================================================================
<===> order/do_not_cross_pseudo_element/pseudo_class_and_element/into_pseudo_element/input.scss
@use "sass:selector";
a {b: selector.unify("::bar:baz", ":foo")}

<===> order/do_not_cross_pseudo_element/pseudo_class_and_element/into_pseudo_element/output.css
a {
b: :foo::bar:baz;
}

<===>
================================================================================
<===> order/do_not_cross_pseudo_element/pseudo_class_and_element/into_same_pseudo_element_and_different_pseudo_class/input.scss
@use "sass:selector";
a {b: selector.unify("::foo:bar", "::foo:baz")}

<===> order/do_not_cross_pseudo_element/pseudo_class_and_element/into_same_pseudo_element_and_different_pseudo_class/output.css
a {
b: ::foo:bar:baz;
}

<===>
================================================================================
<===> order/do_not_cross_pseudo_element/pseudo_class_and_element/into_different_pseudo_element_and_different_pseudo_class/input.scss
@use "sass:selector";
a {b: selector.unify("::foo:bar", "::other:baz")}

<===> order/do_not_cross_pseudo_element/pseudo_class_and_element/into_different_pseudo_element_and_different_pseudo_class/output.css

<===>
================================================================================
<===> order/do_not_cross_pseudo_element/simple/into_pseudo_class_and_element/input.scss
@use "sass:selector";
a {b: selector.unify(".x", ".y::scrollbar:horizontal")}

<===> order/do_not_cross_pseudo_element/simple/into_pseudo_class_and_element/output.css
a {
b: .x.y::scrollbar:horizontal;
}

<===>
================================================================================
<===> order/do_not_cross_pseudo_element/pseudo_element/into_pseudo_class_and_element/input.scss
@use "sass:selector";
a {b: selector.unify(":foo", "::bar:baz")}

<===> order/do_not_cross_pseudo_element/pseudo_element/into_pseudo_class_and_element/output.css
a {
b: :foo::bar:baz;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.bip > .baz {@extend .bar}

<===> output.css
.foo > .bar, .bip.foo > .baz {
.foo > .bar, .foo.bip > .baz {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.b ~ y {@extend x}

<===> output.css
.a ~ x, .a ~ .b ~ y, .b ~ .a ~ y, .b.a ~ y {
.a ~ x, .a ~ .b ~ y, .b ~ .a ~ y, .a.b ~ y {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.b ~ y {@extend x}

<===> output.css
.a + x, .b ~ .a + y, .a.b + y {
.a + x, .b ~ .a + y, .b.a + y {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.b + y {@extend x}

<===> output.css
.a ~ x, .a ~ .b + y, .b.a + y {
.a ~ x, .a ~ .b + y, .a.b + y {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.b > y {@extend x}

<===> output.css
.a.b > x, .b.a > y {
.a.b > x, .a.b > y {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.b > y {@extend x}

<===> output.css
.a > x, .b.a > y {
.a > x, .a.b > y {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.b + y {@extend x}

<===> output.css
.a.b + x, .b.a + y {
.a.b + x, .a.b + y {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.b + y {@extend x}

<===> output.css
.a + x, .b.a + y {
.a + x, .a.b + y {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.c > .d + y {@extend x}

<===> output.css
.a > .b + x, .c.a > .d.b + y {
.a > .b + x, .a.c > .b.d + y {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
.c > y {@extend x}

<===> output.css
.a > .b + x, .c.a > .b + y {
.a > .b + x, .a.c > .b + y {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
y {@extend x}

<===> output.css
.a > .b + x, .c.a > .d.b + y {
.a > .b + x, .a.c > .b.d + y {
a: b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ xml:root .bang-3 { @extend .bar-3}
test: 1;
}

.foo-2:root .bar-2, .baz-2.foo-2:root .bang-2 {
.foo-2:root .bar-2, .foo-2.baz-2:root .bang-2 {
test: 2;
}

html:root .bar-3 {
test: 3;
}

.foo-4:root > .bar-4 .x-4, .baz-4.foo-4:root > .bar-4 .bang-4 .y-4 {
.foo-4:root > .bar-4 .x-4, .foo-4.baz-4:root > .bar-4 .bang-4 .y-4 {
test: 4;
}
Loading