@library/dom 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,46 @@
1
-
2
-  RUN  v5.0.3 /Users/yeonjuan/Desktop/projects/library/packages/dom
3
- Coverage enabled with v8
4
-
5
- ✓ src/uniqueSelectorOf.spec.ts (18 tests) 20ms
6
-
7
-  Test Files  1 passed (1)
8
-  Tests  18 passed (18)
9
-  Start at  18:32:31
10
-  Duration  485ms (environment 84%, transform 5%, tests 5%, worker 5%, import 1%)
11
-
12
-  % Coverage report from v8
13
- -------------------|---------|----------|---------|---------|-------------------
14
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
15
- -------------------|---------|----------|---------|---------|-------------------
16
- All files | 100 | 100 | 100 | 100 |
17
- index.ts | 0 | 0 | 0 | 0 |
18
- ...eSelectorOf.ts | 100 | 100 | 100 | 100 |
19
- -------------------|---------|----------|---------|---------|-------------------
1
+ [?25l
2
+  RUN  v5.0.3 /Users/yeonjuan/Desktop/projects/library/packages/dom
3
+ Coverage enabled with v8
4
+
5
+ [?2026h
6
+  ❯ src/uniqueSelectorOf.spec.ts [queued]
7
+
8
+  Test Files 0 passed (1)
9
+  Tests 0 passed (0)
10
+  Start at 22:55:01
11
+  Duration 605ms
12
+ [?2026l[?2026h ✓ src/uniqueSelectorOf.spec.ts (18 tests) 24ms
13
+ ✓ uniqueSelectorOf (18)
14
+ ✓ should return ID selector when element has an ID 4ms
15
+ ✓ should return unique class selector 5ms
16
+ ✓ should return combined class selector when single classes are not unique 1ms
17
+ ✓ should prefer single class over combined classes when unique 0ms
18
+ ✓ should return path with nth-of-type when classes are not unique 2ms
19
+ ✓ should return shortest unique path 1ms
20
+ ✓ should handle nested elements with same tag 1ms
21
+ ✓ should stop at parent with ID when needed 1ms
22
+ ✓ should return unique selector for deeply nested elements 1ms
23
+ ✓ should handle elements with multiple non-unique classes 1ms
24
+ ✓ should handle body element 0ms
25
+ ✓ should return unique selector even for complex DOM 1ms
26
+ ✓ should handle elements with empty class attribute 0ms
27
+ ✓ should verify returned selector actually queries the correct element 2ms
28
+ ✓ should return combined class selector when unique 1ms
29
+ ✓ should handle elements without parent 0ms
30
+ ✓ should handle case where path never becomes unique until root 1ms
31
+ ✓ should return null when unable to generate unique selector 0ms
32
+
33
+  Test Files  1 passed (1)
34
+  Tests  18 passed (18)
35
+  Start at  22:55:01
36
+  Duration  760ms (environment 87%, worker 4%, tests 4%, transform 4%, import 1%)
37
+
38
+ [?2026l % Coverage report from v8
39
+ ---------------------|---------|----------|---------|---------|-------------------
40
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
41
+ ---------------------|---------|----------|---------|---------|-------------------
42
+ All files  |  100 |  100 |  100 |  100 |  
43
+ index.ts | 0 | 0 | 0 | 0 |  
44
+  uniqueSelectorOf.ts |  100 |  100 |  100 |  100 |  
45
+ ---------------------|---------|----------|---------|---------|-------------------
46
+ [?2026h[?2026l[?25h
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2026-10-04T09:32:32.477Z
119
+ at 2026-10-09T09:53:07.218Z
120
120
  </div>
121
121
  <script src="prettify.js"></script>
122
122
  <script>
@@ -73,7 +73,7 @@
73
73
  <div class='footer quiet pad2 space-top1 center small'>
74
74
  Code coverage generated by
75
75
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
76
- at 2026-10-04T09:32:32.477Z
76
+ at 2026-10-09T09:53:07.218Z
77
77
  </div>
78
78
  <script src="prettify.js"></script>
79
79
  <script>
@@ -228,13 +228,13 @@
228
228
  * @returns {string | null} - A unique query selector string that can be used with document.querySelector.
229
229
  * @example
230
230
  * ```
231
- * import { queryKeyOf } from "@library/dom";
231
+ * import { uniqueSelectorOf } from "@library/dom";
232
232
  *
233
233
  * const el = document.getElementById('myId');
234
- * queryKeyOf(el); // "#myId"
234
+ * uniqueSelectorOf(el); // "#myId"
235
235
  *
236
236
  * const el2 = document.querySelector('.unique-class');
237
- * queryKeyOf(el2); // ".unique-class"
237
+ * uniqueSelectorOf(el2); // ".unique-class"
238
238
  * ```
239
239
  */
240
240
  export function uniqueSelectorOf(element: HTMLElement): string | null {
@@ -307,7 +307,7 @@ export function uniqueSelectorOf(element: HTMLElement): string | null {
307
307
  <div class='footer quiet pad2 space-top1 center small'>
308
308
  Code coverage generated by
309
309
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
310
- at 2026-10-04T09:32:32.477Z
310
+ at 2026-10-09T09:53:07.218Z
311
311
  </div>
312
312
  <script src="prettify.js"></script>
313
313
  <script>
package/llms.txt ADDED
@@ -0,0 +1,45 @@
1
+ <!-- Generated by `yarn docs`. Do not edit by hand. -->
2
+ # @library/dom
3
+
4
+ > A collection of DOM utilities for TypeScript.
5
+
6
+ Install:
7
+
8
+ ```console
9
+ npm install @library/dom
10
+ ```
11
+
12
+ All exports are named ESM/CJS exports, importable as:
13
+
14
+ ```ts
15
+ import { uniqueSelectorOf } from "@library/dom";
16
+ ```
17
+
18
+ ## API
19
+
20
+ ### uniqueSelectorOf
21
+
22
+ Generate the shortest unique querySelector string that identifies the given element.
23
+ Priority: id > unique class > path with nth-of-type
24
+
25
+ ```ts
26
+ function uniqueSelectorOf(element: HTMLElement): string | null
27
+ ```
28
+
29
+ Parameters:
30
+
31
+ - `element`: The HTML element to generate a query selector for.
32
+
33
+ Returns: A unique query selector string that can be used with document.querySelector.
34
+
35
+ Example:
36
+
37
+ ```ts
38
+ import { uniqueSelectorOf } from "@library/dom";
39
+
40
+ const el = document.getElementById('myId');
41
+ uniqueSelectorOf(el); // "#myId"
42
+
43
+ const el2 = document.querySelector('.unique-class');
44
+ uniqueSelectorOf(el2); // ".unique-class"
45
+ ```
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@library/dom",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
+ "description": "A collection of DOM utilities for TypeScript.",
4
5
  "type": "module",
5
6
  "main": "./dist/cjs/index.cjs",
6
7
  "types": "./dist/cjs/index.d.cts",
@@ -17,6 +18,21 @@
17
18
  }
18
19
  }
19
20
  },
21
+ "keywords": [
22
+ "dom",
23
+ "html",
24
+ "typescript",
25
+ "utility"
26
+ ],
27
+ "homepage": "https://github.com/yeonjuan/library/tree/main/packages/dom#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/yeonjuan/library/issues"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/yeonjuan/library.git",
34
+ "directory": "packages/dom"
35
+ },
20
36
  "license": "MIT",
21
37
  "scripts": {
22
38
  "build": "rimraf dist && tsup --tsconfig tsconfig.build.json",
@@ -25,5 +41,5 @@
25
41
  "publishConfig": {
26
42
  "access": "public"
27
43
  },
28
- "gitHead": "e1d0caf47e9ca8305ad84b2e2284c30fbe6b754d"
44
+ "gitHead": "fea3f714ec98af5ce58621c53734e44a62f881df"
29
45
  }
@@ -5,13 +5,13 @@
5
5
  * @returns {string | null} - A unique query selector string that can be used with document.querySelector.
6
6
  * @example
7
7
  * ```
8
- * import { queryKeyOf } from "@library/dom";
8
+ * import { uniqueSelectorOf } from "@library/dom";
9
9
  *
10
10
  * const el = document.getElementById('myId');
11
- * queryKeyOf(el); // "#myId"
11
+ * uniqueSelectorOf(el); // "#myId"
12
12
  *
13
13
  * const el2 = document.querySelector('.unique-class');
14
- * queryKeyOf(el2); // ".unique-class"
14
+ * uniqueSelectorOf(el2); // ".unique-class"
15
15
  * ```
16
16
  */
17
17
  export function uniqueSelectorOf(element: HTMLElement): string | null {