@library/dom 0.0.6

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.
@@ -0,0 +1,19 @@
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
+ -------------------|---------|----------|---------|---------|-------------------
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @library/dom
2
+
3
+ ## Installation
4
+
5
+ **npm**
6
+
7
+ ```console
8
+ npm install @library/dom
9
+ ```
10
+
11
+ **yarn**
12
+
13
+ ```console
14
+ yarn add @library/dom
15
+ ```
16
+
17
+ ## API
18
+
19
+ - [uniqueSelectorOf](#uniqueselectorof)
20
+
21
+ ### uniqueSelectorOf
22
+
23
+ Generate the shortest unique querySelector string that identifies the given element.
24
+ Priority: id > unique class > path with nth-of-type
25
+
26
+ ```ts
27
+ import { uniqueSelectorOf } from "@library/dom";
28
+
29
+ // ID selector (highest priority)
30
+ const el = document.getElementById("myId");
31
+ uniqueSelectorOf(el); // "#myId"
32
+
33
+ // Unique class selector
34
+ const el2 = document.querySelector(".unique-class");
35
+ uniqueSelectorOf(el2); // ".unique-class"
36
+
37
+ // Complex nested structure
38
+ document.body.innerHTML = `
39
+ <div id="container">
40
+ <div class="row">
41
+ <span>A</span>
42
+ <span>B</span>
43
+ </div>
44
+ <div class="row">
45
+ <span>C</span>
46
+ <span>D</span>
47
+ </div>
48
+ </div>
49
+ `;
50
+
51
+ const spanB = document.querySelectorAll("span")[1];
52
+ uniqueSelectorOf(spanB); // "#container > div:nth-of-type(1) > span:nth-of-type(2)"
53
+
54
+ const spanC = document.querySelectorAll("span")[2];
55
+ uniqueSelectorOf(spanC); // "#container > div:nth-of-type(2) > span:nth-of-type(1)"
56
+
57
+ // Detached element (not in document)
58
+ const detachedElement = document.createElement("div");
59
+ uniqueSelectorOf(detachedElement); // null
60
+ ```
@@ -0,0 +1,362 @@
1
+ body,
2
+ html {
3
+ margin: 0;
4
+ padding: 0;
5
+ height: 100%;
6
+ }
7
+ body {
8
+ font-family:
9
+ Helvetica Neue,
10
+ Helvetica,
11
+ Arial;
12
+ font-size: 14px;
13
+ color: #333;
14
+ }
15
+ .small {
16
+ font-size: 12px;
17
+ }
18
+ *,
19
+ *:after,
20
+ *:before {
21
+ -webkit-box-sizing: border-box;
22
+ -moz-box-sizing: border-box;
23
+ box-sizing: border-box;
24
+ }
25
+ h1 {
26
+ font-size: 20px;
27
+ margin: 0;
28
+ }
29
+ h2 {
30
+ font-size: 14px;
31
+ }
32
+ pre {
33
+ font:
34
+ 12px/1.4 Consolas,
35
+ "Liberation Mono",
36
+ Menlo,
37
+ Courier,
38
+ monospace;
39
+ margin: 0;
40
+ padding: 0;
41
+ -moz-tab-size: 2;
42
+ -o-tab-size: 2;
43
+ tab-size: 2;
44
+ }
45
+ a {
46
+ color: #0074d9;
47
+ text-decoration: none;
48
+ }
49
+ a:hover {
50
+ text-decoration: underline;
51
+ }
52
+ .strong {
53
+ font-weight: bold;
54
+ }
55
+ .space-top1 {
56
+ padding: 10px 0 0 0;
57
+ }
58
+ .pad2y {
59
+ padding: 20px 0;
60
+ }
61
+ .pad1y {
62
+ padding: 10px 0;
63
+ }
64
+ .pad2x {
65
+ padding: 0 20px;
66
+ }
67
+ .pad2 {
68
+ padding: 20px;
69
+ }
70
+ .pad1 {
71
+ padding: 10px;
72
+ }
73
+ .space-left2 {
74
+ padding-left: 55px;
75
+ }
76
+ .space-right2 {
77
+ padding-right: 20px;
78
+ }
79
+ .center {
80
+ text-align: center;
81
+ }
82
+ .clearfix {
83
+ display: block;
84
+ }
85
+ .clearfix:after {
86
+ content: "";
87
+ display: block;
88
+ height: 0;
89
+ clear: both;
90
+ visibility: hidden;
91
+ }
92
+ .fl {
93
+ float: left;
94
+ }
95
+ @media only screen and (max-width: 640px) {
96
+ .col3 {
97
+ width: 100%;
98
+ max-width: 100%;
99
+ }
100
+ .hide-mobile {
101
+ display: none !important;
102
+ }
103
+ }
104
+
105
+ .quiet {
106
+ color: #7f7f7f;
107
+ color: rgba(0, 0, 0, 0.5);
108
+ }
109
+ .quiet a {
110
+ opacity: 0.7;
111
+ }
112
+
113
+ .fraction {
114
+ font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
115
+ font-size: 10px;
116
+ color: #555;
117
+ background: #e8e8e8;
118
+ padding: 4px 5px;
119
+ border-radius: 3px;
120
+ vertical-align: middle;
121
+ }
122
+
123
+ div.path a:link,
124
+ div.path a:visited {
125
+ color: #333;
126
+ }
127
+ table.coverage {
128
+ border-collapse: collapse;
129
+ margin: 10px 0 0 0;
130
+ padding: 0;
131
+ }
132
+
133
+ table.coverage td {
134
+ margin: 0;
135
+ padding: 0;
136
+ vertical-align: top;
137
+ }
138
+ table.coverage td.line-count {
139
+ text-align: right;
140
+ padding: 0 5px 0 20px;
141
+ }
142
+ table.coverage td.line-coverage {
143
+ text-align: right;
144
+ padding-right: 10px;
145
+ min-width: 20px;
146
+ }
147
+
148
+ table.coverage td span.cline-any {
149
+ display: inline-block;
150
+ padding: 0 5px;
151
+ width: 100%;
152
+ }
153
+ .missing-if-branch {
154
+ display: inline-block;
155
+ margin-right: 5px;
156
+ border-radius: 3px;
157
+ position: relative;
158
+ padding: 0 4px;
159
+ background: #333;
160
+ color: yellow;
161
+ }
162
+
163
+ .skip-if-branch {
164
+ display: none;
165
+ margin-right: 10px;
166
+ position: relative;
167
+ padding: 0 4px;
168
+ background: #ccc;
169
+ color: white;
170
+ }
171
+ .missing-if-branch .typ,
172
+ .skip-if-branch .typ {
173
+ color: inherit !important;
174
+ }
175
+ .coverage-summary {
176
+ border-collapse: collapse;
177
+ width: 100%;
178
+ }
179
+ .coverage-summary tr {
180
+ border-bottom: 1px solid #bbb;
181
+ }
182
+ .keyline-all {
183
+ border: 1px solid #ddd;
184
+ }
185
+ .coverage-summary td,
186
+ .coverage-summary th {
187
+ padding: 10px;
188
+ }
189
+ .coverage-summary tbody {
190
+ border: 1px solid #bbb;
191
+ }
192
+ .coverage-summary td {
193
+ border-right: 1px solid #bbb;
194
+ }
195
+ .coverage-summary td:last-child {
196
+ border-right: none;
197
+ }
198
+ .coverage-summary th {
199
+ text-align: left;
200
+ font-weight: normal;
201
+ white-space: nowrap;
202
+ }
203
+ .coverage-summary th.file {
204
+ border-right: none !important;
205
+ }
206
+ .coverage-summary th.pct {
207
+ }
208
+ .coverage-summary th.pic,
209
+ .coverage-summary th.abs,
210
+ .coverage-summary td.pct,
211
+ .coverage-summary td.abs {
212
+ text-align: right;
213
+ }
214
+ .coverage-summary td.file {
215
+ white-space: nowrap;
216
+ }
217
+ .coverage-summary td.pic {
218
+ min-width: 120px !important;
219
+ }
220
+ .coverage-summary tfoot td {
221
+ }
222
+
223
+ .coverage-summary .sorter {
224
+ height: 10px;
225
+ width: 7px;
226
+ display: inline-block;
227
+ margin-left: 0.5em;
228
+ background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
229
+ }
230
+ .coverage-summary .sorted .sorter {
231
+ background-position: 0 -20px;
232
+ }
233
+ .coverage-summary .sorted-desc .sorter {
234
+ background-position: 0 -10px;
235
+ }
236
+ .status-line {
237
+ height: 10px;
238
+ }
239
+ /* yellow */
240
+ .cbranch-no {
241
+ background: yellow !important;
242
+ color: #111;
243
+ }
244
+ /* dark red */
245
+ .red.solid,
246
+ .status-line.low,
247
+ .low .cover-fill {
248
+ background: #c21f39;
249
+ }
250
+ .low .chart {
251
+ border: 1px solid #c21f39;
252
+ }
253
+ .highlighted,
254
+ .highlighted .cstat-no,
255
+ .highlighted .fstat-no,
256
+ .highlighted .cbranch-no {
257
+ background: #c21f39 !important;
258
+ }
259
+ /* medium red */
260
+ .cstat-no,
261
+ .fstat-no,
262
+ .cbranch-no,
263
+ .cbranch-no {
264
+ background: #f6c6ce;
265
+ }
266
+ /* light red */
267
+ .low,
268
+ .cline-no {
269
+ background: #fce1e5;
270
+ }
271
+ /* light green */
272
+ .high,
273
+ .cline-yes {
274
+ background: rgb(230, 245, 208);
275
+ }
276
+ /* medium green */
277
+ .cstat-yes {
278
+ background: rgb(161, 215, 106);
279
+ }
280
+ /* dark green */
281
+ .status-line.high,
282
+ .high .cover-fill {
283
+ background: rgb(77, 146, 33);
284
+ }
285
+ .high .chart {
286
+ border: 1px solid rgb(77, 146, 33);
287
+ }
288
+ /* dark yellow (gold) */
289
+ .status-line.medium,
290
+ .medium .cover-fill {
291
+ background: #f9cd0b;
292
+ }
293
+ .medium .chart {
294
+ border: 1px solid #f9cd0b;
295
+ }
296
+ /* light yellow */
297
+ .medium {
298
+ background: #fff4c2;
299
+ }
300
+
301
+ .cstat-skip {
302
+ background: #ddd;
303
+ color: #111;
304
+ }
305
+ .fstat-skip {
306
+ background: #ddd;
307
+ color: #111 !important;
308
+ }
309
+ .cbranch-skip {
310
+ background: #ddd !important;
311
+ color: #111;
312
+ }
313
+
314
+ span.cline-neutral {
315
+ background: #eaeaea;
316
+ }
317
+
318
+ .coverage-summary td.empty {
319
+ opacity: 0.5;
320
+ padding-top: 4px;
321
+ padding-bottom: 4px;
322
+ line-height: 1;
323
+ color: #888;
324
+ }
325
+
326
+ .cover-fill,
327
+ .cover-empty {
328
+ display: inline-block;
329
+ height: 12px;
330
+ }
331
+ .chart {
332
+ line-height: 0;
333
+ }
334
+ .cover-empty {
335
+ background: white;
336
+ }
337
+ .cover-full {
338
+ border-right: none !important;
339
+ }
340
+ pre.prettyprint {
341
+ border: none !important;
342
+ padding: 0 !important;
343
+ margin: 0 !important;
344
+ }
345
+ .com {
346
+ color: #999 !important;
347
+ }
348
+ .ignore-none {
349
+ color: #999;
350
+ font-weight: normal;
351
+ }
352
+
353
+ .wrapper {
354
+ min-height: 100%;
355
+ height: auto !important;
356
+ height: 100%;
357
+ margin: 0 auto -48px;
358
+ }
359
+ .footer,
360
+ .push {
361
+ height: 48px;
362
+ }
@@ -0,0 +1,82 @@
1
+ /* eslint-disable */
2
+ var jumpToCode = (function init() {
3
+ // Classes of code we would like to highlight in the file view
4
+ var missingCoverageClasses = [".cbranch-no", ".cstat-no", ".fstat-no"];
5
+
6
+ // Elements to highlight in the file listing view
7
+ var fileListingElements = ["td.pct.low"];
8
+
9
+ // We don't want to select elements that are direct descendants of another match
10
+ var notSelector = ":not(" + missingCoverageClasses.join("):not(") + ") > "; // becomes `:not(a):not(b) > `
11
+
12
+ // Selector that finds elements on the page to which we can jump
13
+ var selector =
14
+ fileListingElements.join(", ") +
15
+ ", " +
16
+ notSelector +
17
+ missingCoverageClasses.join(", " + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
18
+
19
+ // The NodeList of matching elements
20
+ var missingCoverageElements = document.querySelectorAll(selector);
21
+
22
+ var currentIndex;
23
+
24
+ function toggleClass(index) {
25
+ missingCoverageElements.item(currentIndex).classList.remove("highlighted");
26
+ missingCoverageElements.item(index).classList.add("highlighted");
27
+ }
28
+
29
+ function makeCurrent(index) {
30
+ toggleClass(index);
31
+ currentIndex = index;
32
+ missingCoverageElements.item(index).scrollIntoView({
33
+ behavior: "smooth",
34
+ block: "center",
35
+ inline: "center",
36
+ });
37
+ }
38
+
39
+ function goToPrevious() {
40
+ var nextIndex = 0;
41
+ if (typeof currentIndex !== "number" || currentIndex === 0) {
42
+ nextIndex = missingCoverageElements.length - 1;
43
+ } else if (missingCoverageElements.length > 1) {
44
+ nextIndex = currentIndex - 1;
45
+ }
46
+
47
+ makeCurrent(nextIndex);
48
+ }
49
+
50
+ function goToNext() {
51
+ var nextIndex = 0;
52
+
53
+ if (typeof currentIndex === "number" && currentIndex < missingCoverageElements.length - 1) {
54
+ nextIndex = currentIndex + 1;
55
+ }
56
+
57
+ makeCurrent(nextIndex);
58
+ }
59
+
60
+ return function jump(event) {
61
+ if (
62
+ document.getElementById("fileSearch") === document.activeElement &&
63
+ document.activeElement != null
64
+ ) {
65
+ // if we're currently focused on the search input, we don't want to navigate
66
+ return;
67
+ }
68
+
69
+ switch (event.which) {
70
+ case 78: // n
71
+ case 74: // j
72
+ goToNext();
73
+ break;
74
+ case 66: // b
75
+ case 75: // k
76
+ case 80: // p
77
+ goToPrevious();
78
+ break;
79
+ }
80
+ };
81
+ })();
82
+ window.addEventListener("keydown", jumpToCode);
Binary file
@@ -0,0 +1,131 @@
1
+
2
+ <!doctype html>
3
+ <html lang="en">
4
+
5
+ <head>
6
+ <title>Code coverage report for All files</title>
7
+ <meta charset="utf-8" />
8
+ <link rel="stylesheet" href="prettify.css" />
9
+ <link rel="stylesheet" href="base.css" />
10
+ <link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
11
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
12
+ <style type='text/css'>
13
+ .coverage-summary .sorter {
14
+ background-image: url(sort-arrow-sprite.png);
15
+ }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <div class='wrapper'>
21
+ <div class='pad1'>
22
+ <h1>All files</h1>
23
+ <div class='clearfix'>
24
+
25
+ <div class='fl pad1y space-right2'>
26
+ <span class="strong">100% </span>
27
+ <span class="quiet">Statements</span>
28
+ <span class='fraction'>32/32</span>
29
+ </div>
30
+
31
+
32
+ <div class='fl pad1y space-right2'>
33
+ <span class="strong">100% </span>
34
+ <span class="quiet">Branches</span>
35
+ <span class='fraction'>20/20</span>
36
+ </div>
37
+
38
+
39
+ <div class='fl pad1y space-right2'>
40
+ <span class="strong">100% </span>
41
+ <span class="quiet">Functions</span>
42
+ <span class='fraction'>3/3</span>
43
+ </div>
44
+
45
+
46
+ <div class='fl pad1y space-right2'>
47
+ <span class="strong">100% </span>
48
+ <span class="quiet">Lines</span>
49
+ <span class='fraction'>31/31</span>
50
+ </div>
51
+
52
+
53
+ </div>
54
+ <p class="quiet">
55
+ Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
56
+ </p>
57
+ <template id="filterTemplate">
58
+ <div class="quiet">
59
+ Filter:
60
+ <input type="search" id="fileSearch">
61
+ </div>
62
+ </template>
63
+ </div>
64
+ <div class='status-line high'></div>
65
+ <div class="pad1">
66
+ <table class="coverage-summary">
67
+ <thead>
68
+ <tr>
69
+ <th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
70
+ <th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
71
+ <th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
72
+ <th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
73
+ <th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
74
+ <th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
75
+ <th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
76
+ <th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
77
+ <th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
78
+ <th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
79
+ </tr>
80
+ </thead>
81
+ <tbody><tr>
82
+ <td class="file empty" data-value="index.ts"><a href="index.ts.html">index.ts</a></td>
83
+ <td data-value="0" class="pic empty">
84
+ <div class="chart"><div class="cover-fill" style="width: 0%"></div><div class="cover-empty" style="width: 100%"></div></div>
85
+ </td>
86
+ <td data-value="0" class="pct empty">0%</td>
87
+ <td data-value="0" class="abs empty">0/0</td>
88
+ <td data-value="0" class="pct empty">0%</td>
89
+ <td data-value="0" class="abs empty">0/0</td>
90
+ <td data-value="0" class="pct empty">0%</td>
91
+ <td data-value="0" class="abs empty">0/0</td>
92
+ <td data-value="0" class="pct empty">0%</td>
93
+ <td data-value="0" class="abs empty">0/0</td>
94
+ </tr>
95
+
96
+ <tr>
97
+ <td class="file high" data-value="uniqueSelectorOf.ts"><a href="uniqueSelectorOf.ts.html">uniqueSelectorOf.ts</a></td>
98
+ <td data-value="100" class="pic high">
99
+ <div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
100
+ </td>
101
+ <td data-value="100" class="pct high">100%</td>
102
+ <td data-value="32" class="abs high">32/32</td>
103
+ <td data-value="100" class="pct high">100%</td>
104
+ <td data-value="20" class="abs high">20/20</td>
105
+ <td data-value="100" class="pct high">100%</td>
106
+ <td data-value="3" class="abs high">3/3</td>
107
+ <td data-value="100" class="pct high">100%</td>
108
+ <td data-value="31" class="abs high">31/31</td>
109
+ </tr>
110
+
111
+ </tbody>
112
+ </table>
113
+ </div>
114
+ <div class='push'></div><!-- for sticky footer -->
115
+ </div><!-- /wrapper -->
116
+ <div class='footer quiet pad2 space-top1 center small'>
117
+ Code coverage generated by
118
+ <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
+ at 2026-10-04T09:32:32.477Z
120
+ </div>
121
+ <script src="prettify.js"></script>
122
+ <script>
123
+ window.onload = function () {
124
+ prettyPrint();
125
+ };
126
+ </script>
127
+ <script src="sorter.js"></script>
128
+ <script src="block-navigation.js"></script>
129
+ </body>
130
+ </html>
131
+