@library/dom 0.0.7 → 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.
|
@@ -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-
|
|
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-
|
|
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 {
|
|
231
|
+
* import { uniqueSelectorOf } from "@library/dom";
|
|
232
232
|
*
|
|
233
233
|
* const el = document.getElementById('myId');
|
|
234
|
-
*
|
|
234
|
+
* uniqueSelectorOf(el); // "#myId"
|
|
235
235
|
*
|
|
236
236
|
* const el2 = document.querySelector('.unique-class');
|
|
237
|
-
*
|
|
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-
|
|
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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@library/dom",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "A collection of DOM utilities for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "fea3f714ec98af5ce58621c53734e44a62f881df"
|
|
45
45
|
}
|
package/src/uniqueSelectorOf.ts
CHANGED
|
@@ -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 {
|
|
8
|
+
* import { uniqueSelectorOf } from "@library/dom";
|
|
9
9
|
*
|
|
10
10
|
* const el = document.getElementById('myId');
|
|
11
|
-
*
|
|
11
|
+
* uniqueSelectorOf(el); // "#myId"
|
|
12
12
|
*
|
|
13
13
|
* const el2 = document.querySelector('.unique-class');
|
|
14
|
-
*
|
|
14
|
+
* uniqueSelectorOf(el2); // ".unique-class"
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
export function uniqueSelectorOf(element: HTMLElement): string | null {
|