jj 2.6.0 → 2.8.0
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.
- package/README.md +0 -1
- package/SKILL.md +2 -6
- package/lib/bundle.cjs +24 -17
- package/lib/bundle.cjs.map +1 -1
- package/lib/bundle.d.cts +19 -18
- package/lib/bundle.d.ts +19 -18
- package/lib/bundle.global.js +24 -17
- package/lib/bundle.global.js.map +1 -1
- package/lib/bundle.js +24 -17
- package/lib/bundle.js.map +1 -1
- package/lib/bundle.min.cjs +1 -1
- package/lib/bundle.min.cjs.map +1 -1
- package/lib/bundle.min.d.cts +19 -18
- package/lib/bundle.min.d.ts +19 -18
- package/lib/bundle.min.global.js +1 -1
- package/lib/bundle.min.global.js.map +1 -1
- package/lib/bundle.min.js +1 -1
- package/lib/bundle.min.js.map +1 -1
- package/package.json +15 -18
package/README.md
CHANGED
package/SKILL.md
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: jj
|
|
3
|
-
description:
|
|
4
|
-
Minimal, imperative TypeScript DOM library for AI-assisted development. Use when
|
|
5
|
-
working with DOM manipulation, custom elements, or building lightweight web
|
|
6
|
-
components without frameworks. Triggers on tasks involving direct DOM manipulation,
|
|
7
|
-
Shadow DOM, document fragments, template handling, or converting from React/Vue/jQuery.
|
|
2
|
+
name: jj
|
|
3
|
+
description: Minimal, imperative TypeScript DOM library for AI-assisted development. Use when working with DOM manipulation, custom elements, or building lightweight web components without frameworks. Triggers on tasks involving direct DOM manipulation, Shadow DOM, document fragments, template handling, or converting from React/Vue/jQuery.
|
|
8
4
|
license: MIT
|
|
9
5
|
metadata:
|
|
10
6
|
author: alexewerlof
|
package/lib/bundle.cjs
CHANGED
|
@@ -354,9 +354,9 @@ var JJN = class _JJN extends JJET {
|
|
|
354
354
|
* This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
|
|
355
355
|
*
|
|
356
356
|
* @param x an unknown value
|
|
357
|
-
* @returns true if `x` is a string, Node (or its
|
|
357
|
+
* @returns true if `x` is a string, Node (or its descendent), JJN (or its descendent)
|
|
358
358
|
*/
|
|
359
|
-
static
|
|
359
|
+
static isWrappable(x) {
|
|
360
360
|
return isStr(x) || isA(x, Node) || isA(x, _JJN);
|
|
361
361
|
}
|
|
362
362
|
/**
|
|
@@ -365,6 +365,7 @@ var JJN = class _JJN extends JJET {
|
|
|
365
365
|
* @remarks
|
|
366
366
|
* This function acts as a factory, inspecting the input type and returning the appropriate
|
|
367
367
|
* subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
|
|
368
|
+
* JJN.ts overrides this method to a richer version that handles all subclasses of JJN.
|
|
368
369
|
*
|
|
369
370
|
* @example
|
|
370
371
|
* ```ts
|
|
@@ -377,7 +378,15 @@ var JJN = class _JJN extends JJET {
|
|
|
377
378
|
* @throws {TypeError} If the input is not a Node, string, or JJ wrapper.
|
|
378
379
|
*/
|
|
379
380
|
static wrap(raw) {
|
|
380
|
-
|
|
381
|
+
if (isObj(raw)) {
|
|
382
|
+
if (isA(raw, _JJN)) {
|
|
383
|
+
return raw;
|
|
384
|
+
}
|
|
385
|
+
if (isA(raw, Node)) {
|
|
386
|
+
return new _JJN(raw);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
throw typeErr("raw", "a Node", raw);
|
|
381
390
|
}
|
|
382
391
|
/**
|
|
383
392
|
* Extracts the underlying native DOM node from a wrapper.
|
|
@@ -480,9 +489,9 @@ var JJN = class _JJN extends JJET {
|
|
|
480
489
|
* @returns This instance for chaining.
|
|
481
490
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode | document.createTextNode}
|
|
482
491
|
*/
|
|
483
|
-
addText(
|
|
484
|
-
if (
|
|
485
|
-
this.ref.appendChild(document.createTextNode(
|
|
492
|
+
addText(...textArr) {
|
|
493
|
+
if (textArr) {
|
|
494
|
+
this.ref.appendChild(document.createTextNode(textArr.join("")));
|
|
486
495
|
}
|
|
487
496
|
return this;
|
|
488
497
|
}
|
|
@@ -547,7 +556,7 @@ var JJNx = class extends JJN {
|
|
|
547
556
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/append | Element.append}
|
|
548
557
|
*/
|
|
549
558
|
addChild(...children) {
|
|
550
|
-
const nodes = JJN.unwrapAll(children.filter(JJN.
|
|
559
|
+
const nodes = JJN.unwrapAll(children.filter(JJN.isWrappable));
|
|
551
560
|
this.ref.append(...nodes);
|
|
552
561
|
return this;
|
|
553
562
|
}
|
|
@@ -567,7 +576,7 @@ var JJNx = class extends JJN {
|
|
|
567
576
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend | Element.prepend}
|
|
568
577
|
*/
|
|
569
578
|
preChild(...children) {
|
|
570
|
-
const nodes = JJN.unwrapAll(children.filter(JJN.
|
|
579
|
+
const nodes = JJN.unwrapAll(children.filter(JJN.isWrappable));
|
|
571
580
|
this.ref.prepend(...nodes);
|
|
572
581
|
return this;
|
|
573
582
|
}
|
|
@@ -623,7 +632,7 @@ var JJNx = class extends JJN {
|
|
|
623
632
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.replaceChildren}
|
|
624
633
|
*/
|
|
625
634
|
setChildren(...children) {
|
|
626
|
-
const nodes = JJN.unwrapAll(children.filter(JJN.
|
|
635
|
+
const nodes = JJN.unwrapAll(children.filter(JJN.isWrappable));
|
|
627
636
|
this.ref.replaceChildren(...nodes);
|
|
628
637
|
return this;
|
|
629
638
|
}
|
|
@@ -1385,7 +1394,7 @@ var JJHE = class _JJHE extends JJEx {
|
|
|
1385
1394
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
|
|
1386
1395
|
*/
|
|
1387
1396
|
setText(text) {
|
|
1388
|
-
this.ref.innerText = text
|
|
1397
|
+
this.ref.innerText = text;
|
|
1389
1398
|
return this;
|
|
1390
1399
|
}
|
|
1391
1400
|
};
|
|
@@ -1457,7 +1466,7 @@ var JJT = class _JJT extends JJN {
|
|
|
1457
1466
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1458
1467
|
*/
|
|
1459
1468
|
setText(text) {
|
|
1460
|
-
this.ref.textContent = text
|
|
1469
|
+
this.ref.textContent = text;
|
|
1461
1470
|
return this;
|
|
1462
1471
|
}
|
|
1463
1472
|
/**
|
|
@@ -1470,14 +1479,12 @@ var JJT = class _JJT extends JJN {
|
|
|
1470
1479
|
* console.log(text.getText()) // 'hello world'
|
|
1471
1480
|
* ```
|
|
1472
1481
|
*
|
|
1473
|
-
* @param
|
|
1482
|
+
* @param textArr - The string to add to the existing contents. If null or undefined, nothing is added.
|
|
1474
1483
|
* @returns This instance for chaining.
|
|
1475
1484
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1476
1485
|
*/
|
|
1477
|
-
addText(
|
|
1478
|
-
|
|
1479
|
-
this.ref.textContent += text;
|
|
1480
|
-
}
|
|
1486
|
+
addText(...textArr) {
|
|
1487
|
+
this.setText(this.getText() + textArr.join(""));
|
|
1481
1488
|
return this;
|
|
1482
1489
|
}
|
|
1483
1490
|
/**
|
|
@@ -1636,7 +1643,7 @@ var JJSE = class _JJSE extends JJEx {
|
|
|
1636
1643
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1637
1644
|
*/
|
|
1638
1645
|
setText(text) {
|
|
1639
|
-
this.ref.textContent = text
|
|
1646
|
+
this.ref.textContent = text;
|
|
1640
1647
|
return this;
|
|
1641
1648
|
}
|
|
1642
1649
|
/**
|