@@ -4,74 +4,74 @@ var test = require('tape')
44var u = require ( 'unist-builder' )
55var matches = require ( '..' ) . matches
66
7- test ( 'select.matches()' , function ( t ) {
8- t . test ( 'invalid selector' , function ( st ) {
7+ test ( 'select.matches()' , function ( t ) {
8+ t . test ( 'invalid selector' , function ( st ) {
99 st . throws (
10- function ( ) {
10+ function ( ) {
1111 matches ( )
1212 } ,
1313 / E r r o r : E x p e c t e d ` s t r i n g ` a s s e l e c t o r , n o t ` u n d e f i n e d ` / ,
1414 'should throw without selector'
1515 )
1616
1717 st . throws (
18- function ( ) {
18+ function ( ) {
1919 matches ( [ ] , u ( 'root' , [ ] ) )
2020 } ,
2121 / E r r o r : E x p e c t e d ` s t r i n g ` a s s e l e c t o r , n o t ` ` / ,
2222 'should throw w/ invalid selector (1)'
2323 )
2424
2525 st . throws (
26- function ( ) {
26+ function ( ) {
2727 matches ( '@supports (transform-origin: 5% 5%) {}' , u ( 'root' , [ ] ) )
2828 } ,
2929 / E r r o r : R u l e e x p e c t e d b u t " @ " f o u n d ./ ,
3030 'should throw w/ invalid selector (2)'
3131 )
3232
3333 st . throws (
34- function ( ) {
34+ function ( ) {
3535 matches ( '[foo%=bar]' , u ( 'root' , [ ] ) )
3636 } ,
3737 / E r r o r : E x p e c t e d " = " b u t " % " f o u n d ./ ,
3838 'should throw on invalid attribute operators'
3939 )
4040
4141 st . throws (
42- function ( ) {
42+ function ( ) {
4343 matches ( ':active' , u ( 'root' , [ ] ) )
4444 } ,
4545 / E r r o r : U n k n o w n p s e u d o - s e l e c t o r ` a c t i v e ` / ,
4646 'should throw on invalid pseudo classes'
4747 )
4848
4949 st . throws (
50- function ( ) {
50+ function ( ) {
5151 matches ( ':nth-foo(2n+1)' , u ( 'root' , [ ] ) )
5252 } ,
5353 / E r r o r : U n k n o w n p s e u d o - s e l e c t o r ` n t h - f o o ` / ,
5454 'should throw on invalid pseudo class “functions”'
5555 )
5656
5757 st . throws (
58- function ( ) {
58+ function ( ) {
5959 matches ( '::before' , u ( 'root' , [ ] ) )
6060 } ,
6161 / E r r o r : U n e x p e c t e d p s e u d o - e l e m e n t o r e m p t y p s e u d o - c l a s s / ,
6262 'should throw on invalid pseudo elements'
6363 )
6464
6565 st . throws (
66- function ( ) {
66+ function ( ) {
6767 matches ( 'foo bar' , u ( 'root' , [ ] ) )
6868 } ,
6969 / E r r o r : E x p e c t e d s e l e c t o r w i t h o u t n e s t i n g / ,
7070 'should throw on nested selectors (descendant)'
7171 )
7272
7373 st . throws (
74- function ( ) {
74+ function ( ) {
7575 matches ( 'foo > bar' , u ( 'root' , [ ] ) )
7676 } ,
7777 / E r r o r : E x p e c t e d s e l e c t o r w i t h o u t n e s t i n g / ,
@@ -81,7 +81,7 @@ test('select.matches()', function(t) {
8181 st . end ( )
8282 } )
8383
84- t . test ( 'parent-sensitive pseudo-selectors' , function ( st ) {
84+ t . test ( 'parent-sensitive pseudo-selectors' , function ( st ) {
8585 var simplePseudos = [
8686 'first-child' ,
8787 'first-of-type' ,
@@ -98,19 +98,19 @@ test('select.matches()', function(t) {
9898 'nth-last-of-type'
9999 ]
100100
101- simplePseudos . forEach ( function ( pseudo ) {
101+ simplePseudos . forEach ( function ( pseudo ) {
102102 st . throws (
103- function ( ) {
103+ function ( ) {
104104 matches ( ':' + pseudo , u ( 'root' , [ ] ) )
105105 } ,
106106 new RegExp ( 'Error: Cannot use `:' + pseudo + '` without parent' ) ,
107107 'should throw on `' + pseudo + '`'
108108 )
109109 } )
110110
111- functionalPseudos . forEach ( function ( pseudo ) {
111+ functionalPseudos . forEach ( function ( pseudo ) {
112112 st . throws (
113- function ( ) {
113+ function ( ) {
114114 matches ( ':' + pseudo + '()' , u ( 'root' , [ ] ) )
115115 } ,
116116 new RegExp ( 'Error: Cannot use `:' + pseudo + '` without parent' ) ,
@@ -121,7 +121,7 @@ test('select.matches()', function(t) {
121121 st . end ( )
122122 } )
123123
124- t . test ( 'general' , function ( st ) {
124+ t . test ( 'general' , function ( st ) {
125125 st . notOk (
126126 matches ( '' , u ( 'root' , [ ] ) ) ,
127127 'false for the empty string as selector'
@@ -136,24 +136,24 @@ test('select.matches()', function(t) {
136136 st . end ( )
137137 } )
138138
139- t . test ( 'multiple selectors' , function ( st ) {
139+ t . test ( 'multiple selectors' , function ( st ) {
140140 st . ok ( matches ( 'a, b' , u ( 'a' ) ) , 'true' )
141141 st . notOk ( matches ( 'b, c' , u ( 'a' ) ) , 'false' )
142142
143143 st . end ( )
144144 } )
145145
146- t . test ( 'tag-names: `div`, `*`' , function ( st ) {
146+ t . test ( 'tag-names: `div`, `*`' , function ( st ) {
147147 st . ok ( matches ( '*' , u ( 'a' ) ) , 'true for `*`' )
148148 st . ok ( matches ( 'b' , u ( 'b' ) ) , 'true if types matches' )
149149 st . notOk ( matches ( 'b' , u ( 'a' ) ) , 'false if types don’t matches' )
150150
151151 st . end ( )
152152 } )
153153
154- t . test ( 'id: `#id`' , function ( st ) {
154+ t . test ( 'id: `#id`' , function ( st ) {
155155 st . throws (
156- function ( ) {
156+ function ( ) {
157157 matches ( '#one' , u ( 'a' ) )
158158 } ,
159159 / E r r o r : I n v a l i d s e l e c t o r : i d / ,
@@ -163,9 +163,9 @@ test('select.matches()', function(t) {
163163 st . end ( )
164164 } )
165165
166- t . test ( 'class: `.class`' , function ( st ) {
166+ t . test ( 'class: `.class`' , function ( st ) {
167167 st . throws (
168- function ( ) {
168+ function ( ) {
169169 matches ( '.one' , u ( 'a' ) )
170170 } ,
171171 / E r r o r : I n v a l i d s e l e c t o r : c l a s s / ,
@@ -175,7 +175,7 @@ test('select.matches()', function(t) {
175175 st . end ( )
176176 } )
177177
178- t . test ( 'attributes, existence: `[attr]`' , function ( st ) {
178+ t . test ( 'attributes, existence: `[attr]`' , function ( st ) {
179179 st . ok (
180180 matches ( '[foo]' , u ( 'a' , { foo : 'alpha' } ) ) ,
181181 'true if attribute exists (string)'
@@ -208,7 +208,7 @@ test('select.matches()', function(t) {
208208 st . end ( )
209209 } )
210210
211- t . test ( 'attributes, equality: `[attr=value]`' , function ( st ) {
211+ t . test ( 'attributes, equality: `[attr=value]`' , function ( st ) {
212212 st . ok (
213213 matches ( '[foo=alpha]' , u ( 'a' , { foo : 'alpha' } ) ) ,
214214 'true if attribute matches (string)'
@@ -270,7 +270,7 @@ test('select.matches()', function(t) {
270270 st . end ( )
271271 } )
272272
273- t . test ( 'attributes, begins: `[attr^=value]`' , function ( st ) {
273+ t . test ( 'attributes, begins: `[attr^=value]`' , function ( st ) {
274274 st . ok (
275275 matches ( '[foo^=al]' , u ( 'a' , { foo : 'alpha' } ) ) ,
276276 'true if attribute matches (string)'
@@ -300,7 +300,7 @@ test('select.matches()', function(t) {
300300 st . end ( )
301301 } )
302302
303- t . test ( 'attributes, ends: `[attr$=value]`' , function ( st ) {
303+ t . test ( 'attributes, ends: `[attr$=value]`' , function ( st ) {
304304 st . ok (
305305 matches ( '[foo$=ha]' , u ( 'a' , { foo : 'alpha' } ) ) ,
306306 'true if attribute matches (string)'
@@ -330,7 +330,7 @@ test('select.matches()', function(t) {
330330 st . end ( )
331331 } )
332332
333- t . test ( 'attributes, contains: `[attr*=value]`' , function ( st ) {
333+ t . test ( 'attributes, contains: `[attr*=value]`' , function ( st ) {
334334 st . ok (
335335 matches ( '[foo*=ph]' , u ( 'a' , { foo : 'alpha' } ) ) ,
336336 'true if attribute matches (string)'
@@ -359,7 +359,7 @@ test('select.matches()', function(t) {
359359 st . end ( )
360360 } )
361361
362- t . test ( 'attributes, contains in a list: `[attr~=value]`' , function ( st ) {
362+ t . test ( 'attributes, contains in a list: `[attr~=value]`' , function ( st ) {
363363 st . ok (
364364 matches ( '[foo~=alpha]' , u ( 'a' , { foo : 'alpha' } ) ) ,
365365 'true if attribute matches (string)'
@@ -437,9 +437,9 @@ test('select.matches()', function(t) {
437437 st . end ( )
438438 } )
439439
440- t . test ( 'pseudo-classes' , function ( st ) {
441- ; [ ':any' , ':matches' ] . forEach ( function ( pseudo ) {
442- st . test ( pseudo , function ( sst ) {
440+ t . test ( 'pseudo-classes' , function ( st ) {
441+ ; [ ':any' , ':matches' ] . forEach ( function ( pseudo ) {
442+ st . test ( pseudo , function ( sst ) {
443443 sst . ok (
444444 matches ( pseudo + '(a, [b])' , u ( 'a' ) ) ,
445445 'true if any matches (type)'
@@ -461,7 +461,7 @@ test('select.matches()', function(t) {
461461 } )
462462 } )
463463
464- st . test ( ':not()' , function ( sst ) {
464+ st . test ( ':not()' , function ( sst ) {
465465 sst . notOk ( matches ( ':not(a, [b])' , u ( 'a' ) ) , 'false if any matches (type)' )
466466 sst . notOk (
467467 matches ( ':not(a, [b])' , u ( 'c' , { b : 1 } ) ) ,
@@ -476,12 +476,12 @@ test('select.matches()', function(t) {
476476 sst . end ( )
477477 } )
478478
479- st . test ( ':has' , function ( sst ) {
480- sst . doesNotThrow ( function ( ) {
479+ st . test ( ':has' , function ( sst ) {
480+ sst . doesNotThrow ( function ( ) {
481481 matches ( 'a:not(:has())' , u ( 'b' ) )
482482 } , 'should not throw on empty selectors' )
483483
484- sst . doesNotThrow ( function ( ) {
484+ sst . doesNotThrow ( function ( ) {
485485 matches ( 'a:has()' , u ( 'b' ) )
486486 } , 'should not throw on empty selectors' )
487487
@@ -583,8 +583,8 @@ test('select.matches()', function(t) {
583583
584584 sst . end ( )
585585 } )
586- ; [ ':empty' , ':blank' ] . forEach ( function ( pseudo ) {
587- st . test ( pseudo , function ( sst ) {
586+ ; [ ':empty' , ':blank' ] . forEach ( function ( pseudo ) {
587+ st . test ( pseudo , function ( sst ) {
588588 sst . ok ( matches ( pseudo , u ( 'a' ) ) , 'true for void node' )
589589 sst . ok ( matches ( pseudo , u ( 'a' , [ ] ) ) , 'true for parent without children' )
590590 sst . notOk ( matches ( pseudo , u ( 'a' , '' ) ) , 'false for falsey literal' )
@@ -595,12 +595,12 @@ test('select.matches()', function(t) {
595595 } )
596596 } )
597597
598- st . test ( ':root' , function ( sst ) {
598+ st . test ( ':root' , function ( sst ) {
599599 sst . ok ( matches ( ':root' , u ( 'a' ) ) , 'true' )
600600 sst . end ( )
601601 } )
602602
603- st . test ( ':scope' , function ( sst ) {
603+ st . test ( ':scope' , function ( sst ) {
604604 sst . ok ( matches ( ':scope' , u ( 'a' ) ) , 'true' )
605605 sst . end ( )
606606 } )
0 commit comments