Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit ca3f086

Browse files
authored
Minor cleanup (#131)
* Remove some unnecessary bits * Update test to reflect behavior
1 parent 9261dcd commit ca3f086

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/cashcash.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
class Cash {
22
length = 0;
33

4-
#nodes;
5-
64
constructor(selector, context) {
75
selector = typeof selector === 'string' ? selector.trim() : '';
86

@@ -11,13 +9,12 @@ class Cash {
119
selector = this.selector = typeof context === 'string' && context.trim().length > 0 ? `${context.trim()} ${selector}` : selector;
1210
context = this.context = context instanceof HTMLElement ? context : document;
1311

14-
const nodes = this.nodes = context.querySelectorAll(selector);
12+
const nodes = context.querySelectorAll(selector);
1513

1614
this.length = nodes.length;
1715
this.forEach = nodes.forEach;
1816

19-
// eslint-disable-next-line unicorn/prefer-spread
20-
for (const [index, node] of Array.from(nodes).entries()) {
17+
for (const [index, node] of nodes.entries()) {
2118
this[index] = node;
2219
}
2320
}

test/cashcash.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ test('valid non-matching selector, valid non-matching context (HTMLElement)', t
7272
const context = document.querySelector('#bar');
7373
const cash = CashCash('#foo', context);
7474

75-
t.is(cash.context, context);
75+
t.is(cash.context, document);
7676
t.is(cash.selector, '#foo');
7777
t.is(cash.length, 0);
7878
});
@@ -124,9 +124,9 @@ test('valid matching selector, valid non-matching context (HTMLElement)', t => {
124124
const context = document.querySelector('#foo');
125125
const cash = CashCash('p', context);
126126

127-
t.is(cash.context, context);
127+
t.is(cash.context, document);
128128
t.is(cash.selector, 'p');
129-
t.is(cash.length, 0);
129+
t.is(cash.length, 5);
130130
});
131131

132132
test('valid matching selector, valid matching context (String)', t => {

0 commit comments

Comments
 (0)