Skip to content

Commit

Permalink
feat(arborist): add :overridden pseudo selector
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf authored and fritzy committed Aug 17, 2022
1 parent cd2b1e6 commit d221f72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions workspaces/arborist/lib/query-selector-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ class Results {
!internalSelector.has(node))
}

overriddenPseudo () {
return this.initialItems.filter(node => node.overridden)
}

pathPseudo () {
return this.initialItems.filter(node => {
if (!this.currentAstNode.pathValue) {
Expand Down
8 changes: 6 additions & 2 deletions workspaces/arborist/test/query-selector-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ t.test('query-selector-all', async t => {
│ └── [email protected] (production dep of bar)
├─┬ [email protected] (dev dep of query-selector-all-tests)
│ ├─┬ [email protected] (production dep of foo, deduped)
│ │ └── [email protected] (peer dep of bar)
│ │ └── [email protected] (overridden peer dep of bar)
│ └── [email protected] (production dep of foo)
├── [email protected] (dev dep of query-selector-all-tests)
└─┬ [email protected] (dev dep of query-selector-all-tests)
Expand Down Expand Up @@ -98,7 +98,7 @@ t.test('query-selector-all', async t => {
name: 'bar',
version: '1.4.0',
peerDependencies: {
dasher: '2.0.0',
dasher: '2.1.0',
},
}),
},
Expand Down Expand Up @@ -203,6 +203,9 @@ t.test('query-selector-all', async t => {
bar: '^2.0.0',
ipsum: 'npm:[email protected]',
},
overrides: {
dasher: '2.0.0',
},
devDependencies: {
foo: '^2.0.0',
moo: '^3.0.0',
Expand Down Expand Up @@ -368,6 +371,7 @@ t.test('query-selector-all', async t => {
]],
[':missing', ['missing-dep@^1.0.0']],
[':private', ['[email protected]']],
[':overridden', ['[email protected]']],

// :not pseudo
[':not(#foo)', [
Expand Down

0 comments on commit d221f72

Please sign in to comment.