Skip to content

Commit c89119d

Browse files
nex3mgreter
authored andcommitted
Merge pull request sass#1518 from sass/selector-extend
Add specs for selector-extend()
2 parents 78bd962 + 85494b1 commit c89119d

File tree

893 files changed

+2046
-33375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

893 files changed

+2046
-33375
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Much of the complexity in the algorithm for extend comes from determining which
2+
selectors are superselectors of which others and unifying two selectors, which
3+
are covered more explicitly by specs for the `is-superselector()` and
4+
`selector-unify()` functions, respectively. To avoid unnecessary duplication,
5+
the specs for `selector-extend()` itself don't thoroughly exercise the
6+
superselector or unification logic, and instead focuses on behavior that's
7+
specific to the full extension process.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<===> parent/without_grandparent/simple/input.scss
2+
a {b: selector-extend(".c .d", ".c", ".e")}
3+
4+
<===> parent/without_grandparent/simple/output.css
5+
a {
6+
b: .c .d, .e .d;
7+
}
8+
9+
<===>
10+
================================================================================
11+
<===> parent/without_grandparent/complex/input.scss
12+
a {b: selector-extend(".c .d", ".c", ".e .f")}
13+
14+
<===> parent/without_grandparent/complex/output.css
15+
a {
16+
b: .c .d, .e .f .d;
17+
}
18+
19+
<===>
20+
================================================================================
21+
<===> parent/without_grandparent/list/input.scss
22+
a {b: selector-extend(".c .d", ".c", ".e, .f")}
23+
24+
<===> parent/without_grandparent/list/output.css
25+
a {
26+
b: .c .d, .e .d, .f .d;
27+
}
28+
29+
<===>
30+
================================================================================
31+
<===> parent/with_grandparent/simple/input.scss
32+
a {b: selector-extend(".c .d .e", ".d", ".f")}
33+
34+
<===> parent/with_grandparent/simple/output.css
35+
a {
36+
b: .c .d .e, .c .f .e;
37+
}
38+
39+
<===>
40+
================================================================================
41+
<===> parent/with_grandparent/complex/input.scss
42+
a {b: selector-extend(".c .d .e", ".d", ".f .g")}
43+
44+
<===> parent/with_grandparent/complex/output.css
45+
a {
46+
b: .c .d .e, .c .f .g .e, .f .c .g .e;
47+
}
48+
49+
<===>
50+
================================================================================
51+
<===> parent/with_grandparent/list/input.scss
52+
a {b: selector-extend(".c .d .e", ".d", ".f, .g")}
53+
54+
<===> parent/with_grandparent/list/output.css
55+
a {
56+
b: .c .d .e, .c .f .e, .c .g .e;
57+
}
58+
59+
<===>
60+
================================================================================
61+
<===> trailing_combinator/child/input.scss
62+
a {b: selector-extend(".c .d", ".c", ".e >")}
63+
64+
<===> trailing_combinator/child/output.css
65+
a {
66+
b: .c .d, .e > .d;
67+
}
68+
69+
<===>
70+
================================================================================
71+
<===> trailing_combinator/sibling/input.scss
72+
a {b: selector-extend(".c .d", ".c", ".e ~")}
73+
74+
<===> trailing_combinator/sibling/output.css
75+
a {
76+
b: .c .d, .e ~ .d;
77+
}
78+
79+
<===>
80+
================================================================================
81+
<===> trailing_combinator/next_sibling/input.scss
82+
a {b: selector-extend(".c .d", ".c", ".e +")}
83+
84+
<===> trailing_combinator/next_sibling/output.css
85+
a {
86+
b: .c .d, .e + .d;
87+
}
Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
<===> selector/parent/input.scss
2+
a {b: selector-extend("&", "c", "d")}
3+
4+
<===> selector/parent/error
5+
Error: $selector: Parent selectors aren't allowed here.
6+
,
7+
1 | &
8+
| ^
9+
'
10+
- 1:1 root stylesheet
11+
,
12+
1 | a {b: selector-extend("&", "c", "d")}
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
'
15+
input.scss 1:7 root stylesheet
16+
17+
<===> selector/parent/error-libsass
18+
Error: Parent selectors aren't allowed here.
19+
on line 1:23 of input.scss, in function `selector-extend`
20+
from line 1:7 of input.scss
21+
>> a {b: selector-extend("&", "c", "d")}
22+
23+
----------------------^
24+
25+
<===>
26+
================================================================================
27+
<===> selector/invalid/input.scss
28+
a {b: selector-extend("[c", "d", "e")}
29+
30+
<===> selector/invalid/error
31+
Error: $selector: expected more input.
32+
,
33+
1 | [c
34+
| ^
35+
'
36+
- 1:3 root stylesheet
37+
,
38+
1 | a {b: selector-extend("[c", "d", "e")}
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40+
'
41+
input.scss 1:7 root stylesheet
42+
43+
<===> selector/invalid/error-libsass
44+
Error: invalid operator in attribute selector for c
45+
on line 1:24 of input.scss, in function `selector-extend`
46+
from line 1:7 of input.scss
47+
>> a {b: selector-extend("[c", "d", "e")}
48+
49+
-----------------------^
50+
51+
<===>
52+
================================================================================
53+
<===> selector/type/options.yml
54+
---
55+
:todo:
56+
- sass/libsass#2964
57+
58+
<===> selector/type/input.scss
59+
a {b: selector-extend(1, "c", "d")}
60+
61+
<===> selector/type/error
62+
Error: $selector: 1 is not a valid selector: it must be a string,
63+
a list of strings, or a list of lists of strings.
64+
,
65+
1 | a {b: selector-extend(1, "c", "d")}
66+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67+
'
68+
input.scss 1:7 root stylesheet
69+
70+
<===>
71+
================================================================================
72+
<===> extendee/parent/input.scss
73+
a {b: selector-extend("c", "&", "d")}
74+
75+
<===> extendee/parent/error
76+
Error: $extendee: Parent selectors aren't allowed here.
77+
,
78+
1 | &
79+
| ^
80+
'
81+
- 1:1 root stylesheet
82+
,
83+
1 | a {b: selector-extend("c", "&", "d")}
84+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85+
'
86+
input.scss 1:7 root stylesheet
87+
88+
<===> extendee/parent/error-libsass
89+
Error: Parent selectors aren't allowed here.
90+
on line 1:28 of input.scss, in function `selector-extend`
91+
from line 1:7 of input.scss
92+
>> a {b: selector-extend("c", "&", "d")}
93+
94+
---------------------------^
95+
96+
<===>
97+
================================================================================
98+
<===> extendee/complex/options.yml
99+
---
100+
:todo:
101+
- sass/libsass#3066
102+
103+
<===>
104+
================================================================================
105+
<===> extendee/complex/string/input.scss
106+
a {b: selector-extend("c", "d e", "f")}
107+
108+
<===> extendee/complex/string/error
109+
Error: Can't extend complex selector d e.
110+
,
111+
1 | a {b: selector-extend("c", "d e", "f")}
112+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
113+
'
114+
input.scss 1:7 root stylesheet
115+
116+
<===>
117+
================================================================================
118+
<===> extendee/complex/list/input.scss
119+
a {b: selector-extend("c", d e, "f")}
120+
121+
<===> extendee/complex/list/error
122+
Error: Can't extend complex selector d e.
123+
,
124+
1 | a {b: selector-extend("c", d e, "f")}
125+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126+
'
127+
input.scss 1:7 root stylesheet
128+
129+
<===>
130+
================================================================================
131+
<===> extendee/invalid/input.scss
132+
a {b: selector-extend("c", "[d", "e")}
133+
134+
<===> extendee/invalid/error
135+
Error: $extendee: expected more input.
136+
,
137+
1 | [d
138+
| ^
139+
'
140+
- 1:3 root stylesheet
141+
,
142+
1 | a {b: selector-extend("c", "[d", "e")}
143+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144+
'
145+
input.scss 1:7 root stylesheet
146+
147+
<===> extendee/invalid/error-libsass
148+
Error: invalid operator in attribute selector for d
149+
on line 1:29 of input.scss, in function `selector-extend`
150+
from line 1:7 of input.scss
151+
>> a {b: selector-extend("c", "[d", "e")}
152+
153+
----------------------------^
154+
155+
<===>
156+
================================================================================
157+
<===> extendee/type/options.yml
158+
---
159+
:todo:
160+
- sass/libsass#2964
161+
162+
<===> extendee/type/input.scss
163+
a {b: selector-extend("c", 1, "d")}
164+
165+
<===> extendee/type/error
166+
Error: $extendee: 1 is not a valid selector: it must be a string,
167+
a list of strings, or a list of lists of strings.
168+
,
169+
1 | a {b: selector-extend("c", 1, "d")}
170+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
171+
'
172+
input.scss 1:7 root stylesheet
173+
174+
<===>
175+
================================================================================
176+
<===> extender/parent/input.scss
177+
a {b: selector-extend("c", "d", "&")}
178+
179+
<===> extender/parent/error
180+
Error: $extender: Parent selectors aren't allowed here.
181+
,
182+
1 | &
183+
| ^
184+
'
185+
- 1:1 root stylesheet
186+
,
187+
1 | a {b: selector-extend("c", "d", "&")}
188+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
189+
'
190+
input.scss 1:7 root stylesheet
191+
192+
<===> extender/parent/error-libsass
193+
Error: Parent selectors aren't allowed here.
194+
on line 1:33 of input.scss, in function `selector-extend`
195+
from line 1:7 of input.scss
196+
>> a {b: selector-extend("c", "d", "&")}
197+
198+
--------------------------------^
199+
200+
<===>
201+
================================================================================
202+
<===> extender/invalid/input.scss
203+
a {b: selector-extend("c", "d", "[e")}
204+
205+
<===> extender/invalid/error
206+
Error: $extender: expected more input.
207+
,
208+
1 | [e
209+
| ^
210+
'
211+
- 1:3 root stylesheet
212+
,
213+
1 | a {b: selector-extend("c", "d", "[e")}
214+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
215+
'
216+
input.scss 1:7 root stylesheet
217+
218+
<===> extender/invalid/error-libsass
219+
Error: invalid operator in attribute selector for e
220+
on line 1:34 of input.scss, in function `selector-extend`
221+
from line 1:7 of input.scss
222+
>> a {b: selector-extend("c", "d", "[e")}
223+
224+
---------------------------------^
225+
226+
<===>
227+
================================================================================
228+
<===> extender/type/options.yml
229+
---
230+
:todo:
231+
- sass/libsass#2964
232+
233+
<===> extender/type/input.scss
234+
a {b: selector-extend("c", "d", 1)}
235+
236+
<===> extender/type/error
237+
Error: $extender: 1 is not a valid selector: it must be a string,
238+
a list of strings, or a list of lists of strings.
239+
,
240+
1 | a {b: selector-extend("c", "d", 1)}
241+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
242+
'
243+
input.scss 1:7 root stylesheet
244+
245+
<===>
246+
================================================================================
247+
<===> too_many_args/input.scss
248+
a {b: selector-extend("c", "d", "e", "f")}
249+
250+
<===> too_many_args/error
251+
Error: Only 3 arguments allowed, but 4 were passed.
252+
,--> input.scss
253+
1 | a {b: selector-extend("c", "d", "e", "f")}
254+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation
255+
'
256+
,--> sass:selector
257+
1 | @function extend($selector, $extendee, $extender) {
258+
| ======================================= declaration
259+
'
260+
input.scss 1:7 root stylesheet
261+
262+
<===> too_many_args/error-libsass
263+
Error: wrong number of arguments (4 for 3) for `selector-extend'
264+
on line 1:7 of input.scss
265+
>> a {b: selector-extend("c", "d", "e", "f")}
266+
267+
------^
268+
269+
<===>
270+
================================================================================
271+
<===> too_few_args/input.scss
272+
a {b: selector-extend("c", "d")}
273+
274+
<===> too_few_args/error
275+
Error: Missing argument $extender.
276+
,--> input.scss
277+
1 | a {b: selector-extend("c", "d")}
278+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ invocation
279+
'
280+
,--> sass:selector
281+
1 | @function extend($selector, $extendee, $extender) {
282+
| ======================================= declaration
283+
'
284+
input.scss 1:7 root stylesheet
285+
286+
<===> too_few_args/error-libsass
287+
Error: Function selector-extend is missing argument $extender.
288+
on line 1 of input.scss
289+
>> a {b: selector-extend("c", "d")}
290+
291+
------^

0 commit comments

Comments
 (0)