@@ -16,15 +16,13 @@ function getScopeMatchResults(nodeScopeList, scopeNodeScopeList) {
16
16
17
17
currentPieceOffset = null ;
18
18
var wasEveryPieceFound = true ;
19
- // scopeNodeScopePieces.every(function(scopePiece) {
20
19
for ( scopePieceIndex = 0 ; scopePieceIndex < scopeNodeScopePieces . length ; scopePieceIndex ++ ) {
21
20
var scopePiece = scopeNodeScopePieces [ scopePieceIndex ] ;
22
21
var pieceOffset = currentPieceOffset || 0 ;
23
22
24
23
var foundIndex = - 1 ;
25
24
// Look through the remaining pieces(start from the offset)
26
25
var piecesWeCanMatch = nodeScopePieces . slice ( pieceOffset ) ;
27
- //piecesWeCanMatch.some(function(nodeScopePiece, index) {
28
26
for ( var nodeScopePieceIndex = 0 ; nodeScopePieceIndex < piecesWeCanMatch . length ; nodeScopePieceIndex ++ ) {
29
27
var nodeScopePiece = piecesWeCanMatch [ nodeScopePieceIndex ] ;
30
28
var overallIndex = pieceOffset + nodeScopePieceIndex ;
@@ -55,9 +53,11 @@ function getScopeMatchResults(nodeScopeList, scopeNodeScopeList) {
55
53
56
54
// Handle any direct descendant operators in each piece
57
55
var directDescendantPieces = generateDirectDescendantPiecesFromSelector ( nodeScopePiece ) ;
56
+ // Only try to work out direct descendants if there was the `>` combinator, meaning multiple pieces
58
57
if ( directDescendantPieces . length > 1 ) {
59
58
60
59
var ddNodeScopeList = [ ] . concat ( [ directDescendantPieces ] ) ;
60
+ // Massage into a direct descendant separated list
61
61
var ddScopeList = [ ] . concat ( [
62
62
scopeNodeScopePieces
63
63
. slice ( scopePieceIndex )
@@ -71,24 +71,21 @@ function getScopeMatchResults(nodeScopeList, scopeNodeScopeList) {
71
71
// or there are still more pieces to match in the future
72
72
if ( result . doesMatchScope || scopePieceIndex + 1 < scopeNodeScopePieces . length ) {
73
73
foundIndex = overallIndex ;
74
- // -1 because the fo loop increments at the top
74
+ // Move the scope forward the amount that piece consumed
75
+ // -1 because the of for-loop increments at each iteration
75
76
scopePieceIndex += result . scopePieceIndex - 1 ;
76
77
}
77
78
78
79
break ;
79
80
}
80
-
81
- if ( directDescendantPieces . length > 1 ) {
82
- var asdf = scopeNodeScopePieces . slice ( scopePieceIndex ) ;
83
-
84
- }
85
81
}
86
82
87
83
88
84
var isFurther = foundIndex >= pieceOffset ;
89
85
90
86
currentPieceOffset = foundIndex + 1 ;
91
87
88
+ // Mimicing a `[].every` with a for-loop
92
89
wasEveryPieceFound = wasEveryPieceFound && isFurther ;
93
90
if ( ! wasEveryPieceFound ) {
94
91
break ;
0 commit comments