Skip to content

Commit ea7f88f

Browse files
committed
move needsIndex to seprate file
Tries to remove cyclical dependency any.js -> psudo.js addressing [#9](#9)
1 parent 2269b1c commit ea7f88f

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

lib/any.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module.exports = match
44

55
var zwitch = require('zwitch')
6-
var pseudo = require('./pseudo')
6+
var needs = require('./needs')
77
var test = require('./test')
88
var nest = require('./nest')
99

@@ -75,7 +75,7 @@ function configure(query, state) {
7575
var index = -1
7676

7777
while (++index < pseudos.length) {
78-
if (pseudo.needsIndex.indexOf(pseudos[index].name) > -1) {
78+
if (needs.needsIndex.indexOf(pseudos[index].name) > -1) {
7979
state.index = true
8080
break
8181
}

lib/needs.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* istanbul ignore file - Shouldn’t be invoked */
2+
'use strict'
3+
4+
module.exports = match
5+
6+
function match() {}
7+
8+
match.needsIndex = [
9+
'first-child',
10+
'first-of-type',
11+
'last-child',
12+
'last-of-type',
13+
'nth-child',
14+
'nth-last-child',
15+
'nth-of-type',
16+
'nth-last-of-type',
17+
'only-child',
18+
'only-of-type'
19+
]

lib/pseudo.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@ var anything = require('./any')
99

1010
var is = convert()
1111

12-
match.needsIndex = [
13-
'first-child',
14-
'first-of-type',
15-
'last-child',
16-
'last-of-type',
17-
'nth-child',
18-
'nth-last-child',
19-
'nth-of-type',
20-
'nth-last-of-type',
21-
'only-child',
22-
'only-of-type'
23-
]
24-
2512
var handle = zwitch('name', {
2613
unknown: unknownPseudo,
2714
invalid: invalidPseudo,

0 commit comments

Comments
 (0)