@@ -16,15 +16,13 @@ function getScopeMatchResults(nodeScopeList, scopeNodeScopeList) {
1616
1717 currentPieceOffset = null ;
1818 var wasEveryPieceFound = true ;
19- // scopeNodeScopePieces.every(function(scopePiece) {
2019 for ( scopePieceIndex = 0 ; scopePieceIndex < scopeNodeScopePieces . length ; scopePieceIndex ++ ) {
2120 var scopePiece = scopeNodeScopePieces [ scopePieceIndex ] ;
2221 var pieceOffset = currentPieceOffset || 0 ;
2322
2423 var foundIndex = - 1 ;
2524 // Look through the remaining pieces(start from the offset)
2625 var piecesWeCanMatch = nodeScopePieces . slice ( pieceOffset ) ;
27- //piecesWeCanMatch.some(function(nodeScopePiece, index) {
2826 for ( var nodeScopePieceIndex = 0 ; nodeScopePieceIndex < piecesWeCanMatch . length ; nodeScopePieceIndex ++ ) {
2927 var nodeScopePiece = piecesWeCanMatch [ nodeScopePieceIndex ] ;
3028 var overallIndex = pieceOffset + nodeScopePieceIndex ;
@@ -55,9 +53,11 @@ function getScopeMatchResults(nodeScopeList, scopeNodeScopeList) {
5553
5654 // Handle any direct descendant operators in each piece
5755 var directDescendantPieces = generateDirectDescendantPiecesFromSelector ( nodeScopePiece ) ;
56+ // Only try to work out direct descendants if there was the `>` combinator, meaning multiple pieces
5857 if ( directDescendantPieces . length > 1 ) {
5958
6059 var ddNodeScopeList = [ ] . concat ( [ directDescendantPieces ] ) ;
60+ // Massage into a direct descendant separated list
6161 var ddScopeList = [ ] . concat ( [
6262 scopeNodeScopePieces
6363 . slice ( scopePieceIndex )
@@ -71,24 +71,21 @@ function getScopeMatchResults(nodeScopeList, scopeNodeScopeList) {
7171 // or there are still more pieces to match in the future
7272 if ( result . doesMatchScope || scopePieceIndex + 1 < scopeNodeScopePieces . length ) {
7373 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
7576 scopePieceIndex += result . scopePieceIndex - 1 ;
7677 }
7778
7879 break ;
7980 }
80-
81- if ( directDescendantPieces . length > 1 ) {
82- var asdf = scopeNodeScopePieces . slice ( scopePieceIndex ) ;
83-
84- }
8581 }
8682
8783
8884 var isFurther = foundIndex >= pieceOffset ;
8985
9086 currentPieceOffset = foundIndex + 1 ;
9187
88+ // Mimicing a `[].every` with a for-loop
9289 wasEveryPieceFound = wasEveryPieceFound && isFurther ;
9390 if ( ! wasEveryPieceFound ) {
9491 break ;
0 commit comments