jj 2.7.2 → 2.9.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/lib/bundle.d.cts CHANGED
@@ -217,7 +217,7 @@ declare class JJET<T extends EventTarget = EventTarget> {
217
217
  * @param args - Arguments to pass to the function.
218
218
  * @returns The return value of the function.
219
219
  */
220
- run<R, Args extends any[]>(fn: (this: this, ...args: Args) => R, ...args: Args): R;
220
+ run<R, Args extends unknown[]>(fn: (this: this, ...args: Args) => R, ...args: Args): R;
221
221
  }
222
222
 
223
223
  /**
@@ -249,15 +249,16 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
249
249
  * This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
250
250
  *
251
251
  * @param x an unknown value
252
- * @returns true if `x` is a string, Node (or its descendents), JJN (or its descendents)
252
+ * @returns true if `x` is a string, Node (or its descendent), JJN (or its descendent)
253
253
  */
254
- static isWrapable(x: unknown): x is Wrappable;
254
+ static isWrappable(x: unknown): x is Wrappable;
255
255
  /**
256
256
  * Wraps a native DOM node or string into the most specific JJ wrapper available.
257
257
  *
258
258
  * @remarks
259
259
  * This function acts as a factory, inspecting the input type and returning the appropriate
260
260
  * subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
261
+ * JJN.ts overrides this method to a richer version that handles all subclasses of JJN.
261
262
  *
262
263
  * @example
263
264
  * ```ts
@@ -318,6 +319,39 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
318
319
  * @throws {TypeError} If `ref` is not a Node.
319
320
  */
320
321
  constructor(ref: T);
322
+ /**
323
+ * Gets the parent node wrapped in the most specific JJ wrapper available.
324
+ *
325
+ * @remarks
326
+ * Returns `null` when this node is detached and therefore has no parent.
327
+ *
328
+ * @example
329
+ * ```ts
330
+ * const text = JJT.fromStr('hello')
331
+ * JJHE.create('div').addChild(text)
332
+ * const parent = text.parent // JJHE
333
+ * ```
334
+ *
335
+ * @returns The wrapped parent node, or `null` if this node has no parent.
336
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode | Node.parentNode}
337
+ */
338
+ get parent(): Wrapped | null;
339
+ /**
340
+ * Gets the child nodes wrapped in the most specific JJ wrappers available.
341
+ *
342
+ * @remarks
343
+ * Returns an empty array when this node has no children.
344
+ *
345
+ * @example
346
+ * ```ts
347
+ * const el = JJHE.create('div').addChild('hello', JJHE.create('span'))
348
+ * const children = el.children // [JJT, JJHE]
349
+ * ```
350
+ *
351
+ * @returns The wrapped child nodes.
352
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes | Node.childNodes}
353
+ */
354
+ get children(): Wrapped[];
321
355
  /**
322
356
  * Clones the Node.
323
357
  *
@@ -326,6 +360,23 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
326
360
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode | Node.cloneNode}
327
361
  */
328
362
  clone(deep?: boolean): Wrapped;
363
+ /**
364
+ * Removes this node from its parent.
365
+ *
366
+ * @remarks
367
+ * If the node has no parent, this method does nothing.
368
+ *
369
+ * @example
370
+ * ```ts
371
+ * const el = JJHE.create('div')
372
+ * doc.body.addChild(el)
373
+ * el.rm()
374
+ * ```
375
+ *
376
+ * @returns This instance for chaining.
377
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild | Node.removeChild}
378
+ */
379
+ rm(): this;
329
380
  /**
330
381
  * Creates a Text node from a string and appends it to this Node.
331
382
  *
@@ -342,7 +393,7 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
342
393
  * @returns This instance for chaining.
343
394
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode | document.createTextNode}
344
395
  */
345
- addText(text?: string | null): this;
396
+ addText(...textArr: unknown[]): this;
346
397
  }
347
398
 
348
399
  declare abstract class JJNx<T extends Element | Document | DocumentFragment> extends JJN<T> {
@@ -658,8 +709,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
658
709
  * @throws {TypeError} If arguments are invalid types.
659
710
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute | Element.setAttribute}
660
711
  */
661
- setAttr(name: string, value: any): this;
662
- setAttr(obj: Record<string, any>): this;
712
+ setAttr(name: string, value: unknown): this;
713
+ setAttr(obj: Record<string, unknown>): this;
663
714
  /**
664
715
  * Removes one or more attributes from the Element.
665
716
  *
@@ -712,8 +763,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
712
763
  *
713
764
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes | ARIA Attributes}
714
765
  */
715
- setAria(name: string, value: any): this;
716
- setAria(obj: Record<string, any>): this;
766
+ setAria(name: string, value: unknown): this;
767
+ setAria(obj: Record<string, unknown>): this;
717
768
  /**
718
769
  * Removes one or more ARIA attributes from the Element.
719
770
  *
@@ -955,14 +1006,14 @@ declare abstract class JJEx<T extends HTMLElement | SVGElement> extends JJE<T> {
955
1006
  * ```ts
956
1007
  * el.setData('myKey', 'myValue') // Single
957
1008
  * el.setData({ myKey: 'myValue', otherKey: 'otherValue' }) // Multiple
958
- * el.setData('count', 42) // Numbers are automatically converted
1009
+ * el.setData('count', 42) // Numbers are automatically converted to strings
959
1010
  * ```
960
1011
  *
961
1012
  * @throws {TypeError} If arguments are invalid types.
962
1013
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
963
1014
  */
964
- setData(name: string, value: any): this;
965
- setData(obj: Record<string, any>): this;
1015
+ setData(name: string, value?: string): this;
1016
+ setData(obj: Record<string, string | undefined>): this;
966
1017
  /**
967
1018
  * Removes one or more data attributes from the HTMLElement.
968
1019
  *
@@ -1049,7 +1100,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
1049
1100
  * @throws {Error} If the HTMLElement does not have a value property.
1050
1101
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
1051
1102
  */
1052
- setValue(value: any): this;
1103
+ setValue(value: unknown): this;
1053
1104
  /**
1054
1105
  * Focuses the HTMLElement.
1055
1106
  *
@@ -1086,7 +1137,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
1086
1137
  * @returns This instance for chaining.
1087
1138
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
1088
1139
  */
1089
- setText(text?: any): this;
1140
+ setText(text?: unknown): this;
1090
1141
  }
1091
1142
 
1092
1143
  /**
@@ -1229,7 +1280,7 @@ declare class JJSE<T extends SVGElement = SVGElement> extends JJEx<T> {
1229
1280
  * @returns This instance for chaining.
1230
1281
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
1231
1282
  */
1232
- setText(text?: any): this;
1283
+ setText(text?: unknown): this;
1233
1284
  /**
1234
1285
  * Sets the fill attribute.
1235
1286
  *
@@ -1367,7 +1418,7 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
1367
1418
  * @returns This instance for chaining.
1368
1419
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
1369
1420
  */
1370
- setText(text?: any): this;
1421
+ setText(text?: unknown): this;
1371
1422
  /**
1372
1423
  * Appends text to the existing content.
1373
1424
  *
@@ -1378,11 +1429,11 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
1378
1429
  * console.log(text.getText()) // 'hello world'
1379
1430
  * ```
1380
1431
  *
1381
- * @param text - The string to add to the existing contents. If null or undefined, nothing is added.
1432
+ * @param textArr - The string to add to the existing contents. If null or undefined, nothing is added.
1382
1433
  * @returns This instance for chaining.
1383
1434
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
1384
1435
  */
1385
- addText(text?: any): this;
1436
+ addText(...textArr: unknown[]): this;
1386
1437
  /**
1387
1438
  * Clears the text content of the Text node.
1388
1439
  *
@@ -1659,7 +1710,7 @@ declare function fetchStyle(url: URL | string): Promise<CSSStyleSheet>;
1659
1710
  * @returns `true` if it tried to set the attribute; otherwise `false`.
1660
1711
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes | Responding to attribute changes}
1661
1712
  */
1662
- declare function attr2prop(instance: HTMLElement, name: string, oldValue: any, newValue: any): boolean;
1713
+ declare function attr2prop(instance: HTMLElement, name: string, oldValue: unknown, newValue: unknown): boolean;
1663
1714
  /**
1664
1715
  * Registers the custom element with the browser and waits till it is defined.
1665
1716
  *
package/lib/bundle.d.ts CHANGED
@@ -217,7 +217,7 @@ declare class JJET<T extends EventTarget = EventTarget> {
217
217
  * @param args - Arguments to pass to the function.
218
218
  * @returns The return value of the function.
219
219
  */
220
- run<R, Args extends any[]>(fn: (this: this, ...args: Args) => R, ...args: Args): R;
220
+ run<R, Args extends unknown[]>(fn: (this: this, ...args: Args) => R, ...args: Args): R;
221
221
  }
222
222
 
223
223
  /**
@@ -249,15 +249,16 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
249
249
  * This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
250
250
  *
251
251
  * @param x an unknown value
252
- * @returns true if `x` is a string, Node (or its descendents), JJN (or its descendents)
252
+ * @returns true if `x` is a string, Node (or its descendent), JJN (or its descendent)
253
253
  */
254
- static isWrapable(x: unknown): x is Wrappable;
254
+ static isWrappable(x: unknown): x is Wrappable;
255
255
  /**
256
256
  * Wraps a native DOM node or string into the most specific JJ wrapper available.
257
257
  *
258
258
  * @remarks
259
259
  * This function acts as a factory, inspecting the input type and returning the appropriate
260
260
  * subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
261
+ * JJN.ts overrides this method to a richer version that handles all subclasses of JJN.
261
262
  *
262
263
  * @example
263
264
  * ```ts
@@ -318,6 +319,39 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
318
319
  * @throws {TypeError} If `ref` is not a Node.
319
320
  */
320
321
  constructor(ref: T);
322
+ /**
323
+ * Gets the parent node wrapped in the most specific JJ wrapper available.
324
+ *
325
+ * @remarks
326
+ * Returns `null` when this node is detached and therefore has no parent.
327
+ *
328
+ * @example
329
+ * ```ts
330
+ * const text = JJT.fromStr('hello')
331
+ * JJHE.create('div').addChild(text)
332
+ * const parent = text.parent // JJHE
333
+ * ```
334
+ *
335
+ * @returns The wrapped parent node, or `null` if this node has no parent.
336
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode | Node.parentNode}
337
+ */
338
+ get parent(): Wrapped | null;
339
+ /**
340
+ * Gets the child nodes wrapped in the most specific JJ wrappers available.
341
+ *
342
+ * @remarks
343
+ * Returns an empty array when this node has no children.
344
+ *
345
+ * @example
346
+ * ```ts
347
+ * const el = JJHE.create('div').addChild('hello', JJHE.create('span'))
348
+ * const children = el.children // [JJT, JJHE]
349
+ * ```
350
+ *
351
+ * @returns The wrapped child nodes.
352
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes | Node.childNodes}
353
+ */
354
+ get children(): Wrapped[];
321
355
  /**
322
356
  * Clones the Node.
323
357
  *
@@ -326,6 +360,23 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
326
360
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode | Node.cloneNode}
327
361
  */
328
362
  clone(deep?: boolean): Wrapped;
363
+ /**
364
+ * Removes this node from its parent.
365
+ *
366
+ * @remarks
367
+ * If the node has no parent, this method does nothing.
368
+ *
369
+ * @example
370
+ * ```ts
371
+ * const el = JJHE.create('div')
372
+ * doc.body.addChild(el)
373
+ * el.rm()
374
+ * ```
375
+ *
376
+ * @returns This instance for chaining.
377
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild | Node.removeChild}
378
+ */
379
+ rm(): this;
329
380
  /**
330
381
  * Creates a Text node from a string and appends it to this Node.
331
382
  *
@@ -342,7 +393,7 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
342
393
  * @returns This instance for chaining.
343
394
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode | document.createTextNode}
344
395
  */
345
- addText(text?: string | null): this;
396
+ addText(...textArr: unknown[]): this;
346
397
  }
347
398
 
348
399
  declare abstract class JJNx<T extends Element | Document | DocumentFragment> extends JJN<T> {
@@ -658,8 +709,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
658
709
  * @throws {TypeError} If arguments are invalid types.
659
710
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute | Element.setAttribute}
660
711
  */
661
- setAttr(name: string, value: any): this;
662
- setAttr(obj: Record<string, any>): this;
712
+ setAttr(name: string, value: unknown): this;
713
+ setAttr(obj: Record<string, unknown>): this;
663
714
  /**
664
715
  * Removes one or more attributes from the Element.
665
716
  *
@@ -712,8 +763,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
712
763
  *
713
764
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes | ARIA Attributes}
714
765
  */
715
- setAria(name: string, value: any): this;
716
- setAria(obj: Record<string, any>): this;
766
+ setAria(name: string, value: unknown): this;
767
+ setAria(obj: Record<string, unknown>): this;
717
768
  /**
718
769
  * Removes one or more ARIA attributes from the Element.
719
770
  *
@@ -955,14 +1006,14 @@ declare abstract class JJEx<T extends HTMLElement | SVGElement> extends JJE<T> {
955
1006
  * ```ts
956
1007
  * el.setData('myKey', 'myValue') // Single
957
1008
  * el.setData({ myKey: 'myValue', otherKey: 'otherValue' }) // Multiple
958
- * el.setData('count', 42) // Numbers are automatically converted
1009
+ * el.setData('count', 42) // Numbers are automatically converted to strings
959
1010
  * ```
960
1011
  *
961
1012
  * @throws {TypeError} If arguments are invalid types.
962
1013
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
963
1014
  */
964
- setData(name: string, value: any): this;
965
- setData(obj: Record<string, any>): this;
1015
+ setData(name: string, value?: string): this;
1016
+ setData(obj: Record<string, string | undefined>): this;
966
1017
  /**
967
1018
  * Removes one or more data attributes from the HTMLElement.
968
1019
  *
@@ -1049,7 +1100,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
1049
1100
  * @throws {Error} If the HTMLElement does not have a value property.
1050
1101
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
1051
1102
  */
1052
- setValue(value: any): this;
1103
+ setValue(value: unknown): this;
1053
1104
  /**
1054
1105
  * Focuses the HTMLElement.
1055
1106
  *
@@ -1086,7 +1137,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
1086
1137
  * @returns This instance for chaining.
1087
1138
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
1088
1139
  */
1089
- setText(text?: any): this;
1140
+ setText(text?: unknown): this;
1090
1141
  }
1091
1142
 
1092
1143
  /**
@@ -1229,7 +1280,7 @@ declare class JJSE<T extends SVGElement = SVGElement> extends JJEx<T> {
1229
1280
  * @returns This instance for chaining.
1230
1281
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
1231
1282
  */
1232
- setText(text?: any): this;
1283
+ setText(text?: unknown): this;
1233
1284
  /**
1234
1285
  * Sets the fill attribute.
1235
1286
  *
@@ -1367,7 +1418,7 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
1367
1418
  * @returns This instance for chaining.
1368
1419
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
1369
1420
  */
1370
- setText(text?: any): this;
1421
+ setText(text?: unknown): this;
1371
1422
  /**
1372
1423
  * Appends text to the existing content.
1373
1424
  *
@@ -1378,11 +1429,11 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
1378
1429
  * console.log(text.getText()) // 'hello world'
1379
1430
  * ```
1380
1431
  *
1381
- * @param text - The string to add to the existing contents. If null or undefined, nothing is added.
1432
+ * @param textArr - The string to add to the existing contents. If null or undefined, nothing is added.
1382
1433
  * @returns This instance for chaining.
1383
1434
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
1384
1435
  */
1385
- addText(text?: any): this;
1436
+ addText(...textArr: unknown[]): this;
1386
1437
  /**
1387
1438
  * Clears the text content of the Text node.
1388
1439
  *
@@ -1659,7 +1710,7 @@ declare function fetchStyle(url: URL | string): Promise<CSSStyleSheet>;
1659
1710
  * @returns `true` if it tried to set the attribute; otherwise `false`.
1660
1711
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes | Responding to attribute changes}
1661
1712
  */
1662
- declare function attr2prop(instance: HTMLElement, name: string, oldValue: any, newValue: any): boolean;
1713
+ declare function attr2prop(instance: HTMLElement, name: string, oldValue: unknown, newValue: unknown): boolean;
1663
1714
  /**
1664
1715
  * Registers the custom element with the browser and waits till it is defined.
1665
1716
  *
@@ -305,9 +305,9 @@
305
305
  * This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
306
306
  *
307
307
  * @param x an unknown value
308
- * @returns true if `x` is a string, Node (or its descendents), JJN (or its descendents)
308
+ * @returns true if `x` is a string, Node (or its descendent), JJN (or its descendent)
309
309
  */
310
- static isWrapable(x) {
310
+ static isWrappable(x) {
311
311
  return isStr(x) || isA(x, Node) || isA(x, _JJN);
312
312
  }
313
313
  /**
@@ -316,6 +316,7 @@
316
316
  * @remarks
317
317
  * This function acts as a factory, inspecting the input type and returning the appropriate
318
318
  * subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
319
+ * JJN.ts overrides this method to a richer version that handles all subclasses of JJN.
319
320
  *
320
321
  * @example
321
322
  * ```ts
@@ -328,7 +329,15 @@
328
329
  * @throws {TypeError} If the input is not a Node, string, or JJ wrapper.
329
330
  */
330
331
  static wrap(raw) {
331
- throw new ReferenceError(`The mixin is supposed to override this method.`);
332
+ if (isObj(raw)) {
333
+ if (isA(raw, _JJN)) {
334
+ return raw;
335
+ }
336
+ if (isA(raw, Node)) {
337
+ return new _JJN(raw);
338
+ }
339
+ }
340
+ throw typeErr("raw", "a Node", raw);
332
341
  }
333
342
  /**
334
343
  * Extracts the underlying native DOM node from a wrapper.
@@ -405,6 +414,44 @@
405
414
  }
406
415
  super(ref);
407
416
  }
417
+ /**
418
+ * Gets the parent node wrapped in the most specific JJ wrapper available.
419
+ *
420
+ * @remarks
421
+ * Returns `null` when this node is detached and therefore has no parent.
422
+ *
423
+ * @example
424
+ * ```ts
425
+ * const text = JJT.fromStr('hello')
426
+ * JJHE.create('div').addChild(text)
427
+ * const parent = text.parent // JJHE
428
+ * ```
429
+ *
430
+ * @returns The wrapped parent node, or `null` if this node has no parent.
431
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode | Node.parentNode}
432
+ */
433
+ get parent() {
434
+ const { parentNode } = this.ref;
435
+ return parentNode ? _JJN.wrap(parentNode) : null;
436
+ }
437
+ /**
438
+ * Gets the child nodes wrapped in the most specific JJ wrappers available.
439
+ *
440
+ * @remarks
441
+ * Returns an empty array when this node has no children.
442
+ *
443
+ * @example
444
+ * ```ts
445
+ * const el = JJHE.create('div').addChild('hello', JJHE.create('span'))
446
+ * const children = el.children // [JJT, JJHE]
447
+ * ```
448
+ *
449
+ * @returns The wrapped child nodes.
450
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes | Node.childNodes}
451
+ */
452
+ get children() {
453
+ return _JJN.wrapAll(this.ref.childNodes);
454
+ }
408
455
  /**
409
456
  * Clones the Node.
410
457
  *
@@ -415,6 +462,29 @@
415
462
  clone(deep) {
416
463
  return _JJN.wrap(this.ref.cloneNode(deep));
417
464
  }
465
+ /**
466
+ * Removes this node from its parent.
467
+ *
468
+ * @remarks
469
+ * If the node has no parent, this method does nothing.
470
+ *
471
+ * @example
472
+ * ```ts
473
+ * const el = JJHE.create('div')
474
+ * doc.body.addChild(el)
475
+ * el.rm()
476
+ * ```
477
+ *
478
+ * @returns This instance for chaining.
479
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild | Node.removeChild}
480
+ */
481
+ rm() {
482
+ const { parentNode } = this.ref;
483
+ if (parentNode) {
484
+ parentNode.removeChild(this.ref);
485
+ }
486
+ return this;
487
+ }
418
488
  /**
419
489
  * Creates a Text node from a string and appends it to this Node.
420
490
  *
@@ -431,9 +501,9 @@
431
501
  * @returns This instance for chaining.
432
502
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode | document.createTextNode}
433
503
  */
434
- addText(text) {
435
- if (text) {
436
- this.ref.appendChild(document.createTextNode(text));
504
+ addText(...textArr) {
505
+ if (textArr) {
506
+ this.ref.appendChild(document.createTextNode(textArr.join("")));
437
507
  }
438
508
  return this;
439
509
  }
@@ -498,7 +568,7 @@
498
568
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/append | Element.append}
499
569
  */
500
570
  addChild(...children) {
501
- const nodes = JJN.unwrapAll(children.filter(JJN.isWrapable));
571
+ const nodes = JJN.unwrapAll(children.filter(JJN.isWrappable));
502
572
  this.ref.append(...nodes);
503
573
  return this;
504
574
  }
@@ -518,7 +588,7 @@
518
588
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend | Element.prepend}
519
589
  */
520
590
  preChild(...children) {
521
- const nodes = JJN.unwrapAll(children.filter(JJN.isWrapable));
591
+ const nodes = JJN.unwrapAll(children.filter(JJN.isWrappable));
522
592
  this.ref.prepend(...nodes);
523
593
  return this;
524
594
  }
@@ -574,7 +644,7 @@
574
644
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren | Element.replaceChildren}
575
645
  */
576
646
  setChildren(...children) {
577
- const nodes = JJN.unwrapAll(children.filter(JJN.isWrapable));
647
+ const nodes = JJN.unwrapAll(children.filter(JJN.isWrappable));
578
648
  this.ref.replaceChildren(...nodes);
579
649
  return this;
580
650
  }
@@ -1336,7 +1406,7 @@
1336
1406
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
1337
1407
  */
1338
1408
  setText(text) {
1339
- this.ref.innerText = text ?? "";
1409
+ this.ref.innerText = text;
1340
1410
  return this;
1341
1411
  }
1342
1412
  };
@@ -1408,7 +1478,7 @@
1408
1478
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
1409
1479
  */
1410
1480
  setText(text) {
1411
- this.ref.textContent = text ?? null;
1481
+ this.ref.textContent = text;
1412
1482
  return this;
1413
1483
  }
1414
1484
  /**
@@ -1421,14 +1491,12 @@
1421
1491
  * console.log(text.getText()) // 'hello world'
1422
1492
  * ```
1423
1493
  *
1424
- * @param text - The string to add to the existing contents. If null or undefined, nothing is added.
1494
+ * @param textArr - The string to add to the existing contents. If null or undefined, nothing is added.
1425
1495
  * @returns This instance for chaining.
1426
1496
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
1427
1497
  */
1428
- addText(text) {
1429
- if (text != null) {
1430
- this.ref.textContent += text;
1431
- }
1498
+ addText(...textArr) {
1499
+ this.setText(this.getText() + textArr.join(""));
1432
1500
  return this;
1433
1501
  }
1434
1502
  /**
@@ -1587,7 +1655,7 @@
1587
1655
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
1588
1656
  */
1589
1657
  setText(text) {
1590
- this.ref.textContent = text ?? "";
1658
+ this.ref.textContent = text;
1591
1659
  return this;
1592
1660
  }
1593
1661
  /**