Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(arborist): add :overridden pseudo selector
  • 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
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
Expand Up @@ -28,7 +28,7 @@ t.test('query-selector-all', async t => {
│ └── moo@3.0.0 (production dep of bar)
├─┬ foo@2.2.2 (dev dep of query-selector-all-tests)
│ ├─┬ bar@1.4.0 (production dep of foo, deduped)
│ │ └── dasher@2.0.0 (peer dep of bar)
│ │ └── dasher@2.0.0 (overridden peer dep of bar)
│ └── dash-separated-pkg@1.0.0 (production dep of foo)
├── moo@3.0.0 (dev dep of query-selector-all-tests)
└─┬ recur@1.0.0 (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:sit@1.0.0',
},
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', ['b@1.0.0']],
[':overridden', ['dasher@2.0.0']],

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

0 comments on commit d221f72

Please sign in to comment.