@@ -20,6 +20,7 @@ class Results {
2020 this . #currentAstSelector = rootAstNode . nodes [ 0 ]
2121 }
2222
23+ /* eslint-disable-next-line accessor-pairs */
2324 set currentAstSelector ( value ) {
2425 this . #currentAstSelector = value
2526 }
@@ -35,7 +36,7 @@ class Results {
3536 // when collecting results to a root astNode, we traverse the list of
3637 // child selector nodes and collect all of their resulting arborist nodes
3738 // into a single/flat Set of items, this ensures we also deduplicate items
38- collect ( rootAstNode ) {
39+ collect ( rootAstNode ) {
3940 const acc = new Set ( )
4041 for ( const n of rootAstNode . nodes ) {
4142 for ( const node of this . #results. get ( n ) ) {
@@ -51,25 +52,28 @@ const retrieveNodesFromParsedAst = async ({
5152 initialItems,
5253 inventory,
5354 rootAstNode,
54- targetNode
55+ targetNode,
5556} ) => {
5657 if ( ! rootAstNode . nodes ) {
5758 return new Set ( )
5859 }
5960
6061 const ArboristNode = targetNode . constructor
6162
62- let results = new Results ( rootAstNode )
63+ const results = new Results ( rootAstNode )
6364 let currentAstNode = rootAstNode
64- let prevAstNode = null
6565 let pendingCombinator = null
6666
6767 results . currentResult = initialItems
6868
6969 // maps containing the logic to parse each of the supported css selectors
7070 const attributeOperatorsMap = new Map ( Object . entries ( {
71- '' ( { attribute, value, pkg } ) { return Boolean ( pkg [ attribute ] ) } ,
72- '=' ( { attribute, value, pkg } ) { return String ( pkg [ attribute ] || '' ) === value } ,
71+ '' ( { attribute, value, pkg } ) {
72+ return Boolean ( pkg [ attribute ] )
73+ } ,
74+ '=' ( { attribute, value, pkg } ) {
75+ return String ( pkg [ attribute ] || '' ) === value
76+ } ,
7377 '~=' ( { attribute, value, pkg } ) {
7478 return ( String ( pkg [ attribute ] || '' ) . match ( / \w + / g) || [ ] ) . includes ( value )
7579 } ,
@@ -318,8 +322,8 @@ const retrieveNodesFromParsedAst = async ({
318322 return getInitialItems ( ) . filter ( node =>
319323 currentAstNode . pathValue
320324 ? minimatch (
321- node . realpath ,
322- resolve ( node . root . realpath , currentAstNode . pathValue )
325+ node . realpath . replace ( / \\ + / g , '/' ) ,
326+ resolve ( node . root . realpath , currentAstNode . pathValue ) . replace ( / \\ + / g , '/' )
323327 )
324328 : true
325329 )
@@ -356,7 +360,7 @@ const retrieveNodesFromParsedAst = async ({
356360 // of filtered results, for example a query for `.workspace` actually
357361 // means the same as `*.workspace` so we want to start with the full
358362 // inventory if that's the first ast node we're reading but if it appears
359- // in the middle of a query it should respect the previous filtered
363+ // in the middle of a query it should respect the previous filtered
360364 // results, combinators are a special case in which we always want to
361365 // have the complete inventory list in order to use the left-hand side
362366 // ast node as a filter combined with the element on its right-hand side
@@ -410,7 +414,8 @@ const retrieveNodesFromParsedAst = async ({
410414 attribute,
411415 value,
412416 pkg : node . package ,
413- } ) } )
417+ } )
418+ } )
414419 results . currentResult =
415420 await processPendingCombinator ( prevResults , nextResults )
416421 }
@@ -472,7 +477,7 @@ const retrieveNodesFromParsedAst = async ({
472477 // to a function that parses it
473478 const retrieveByType = new Map ( Object . entries ( {
474479 attribute,
475- ' class' : classType ,
480+ class : classType ,
476481 combinator,
477482 id,
478483 pseudo,
@@ -488,7 +493,6 @@ const retrieveNodesFromParsedAst = async ({
488493 } )
489494
490495 for ( const nextAstNode of astNodeQueue ) {
491- prevAstNode = currentAstNode
492496 currentAstNode = nextAstNode
493497
494498 const updateResult =
@@ -509,7 +513,7 @@ const querySelectorAll = async (targetNode, query) => {
509513 initialItems : inventory ,
510514 inventory,
511515 rootAstNode,
512- targetNode
516+ targetNode,
513517 } )
514518
515519 // returns nodes ordered by realpath
0 commit comments