jj 2.8.0 → 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.js CHANGED
@@ -412,6 +412,44 @@ var JJN = class _JJN extends JJET {
412
412
  }
413
413
  super(ref);
414
414
  }
415
+ /**
416
+ * Gets the parent node wrapped in the most specific JJ wrapper available.
417
+ *
418
+ * @remarks
419
+ * Returns `null` when this node is detached and therefore has no parent.
420
+ *
421
+ * @example
422
+ * ```ts
423
+ * const text = JJT.fromStr('hello')
424
+ * JJHE.create('div').addChild(text)
425
+ * const parent = text.parent // JJHE
426
+ * ```
427
+ *
428
+ * @returns The wrapped parent node, or `null` if this node has no parent.
429
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode | Node.parentNode}
430
+ */
431
+ get parent() {
432
+ const { parentNode } = this.ref;
433
+ return parentNode ? _JJN.wrap(parentNode) : null;
434
+ }
435
+ /**
436
+ * Gets the child nodes wrapped in the most specific JJ wrappers available.
437
+ *
438
+ * @remarks
439
+ * Returns an empty array when this node has no children.
440
+ *
441
+ * @example
442
+ * ```ts
443
+ * const el = JJHE.create('div').addChild('hello', JJHE.create('span'))
444
+ * const children = el.children // [JJT, JJHE]
445
+ * ```
446
+ *
447
+ * @returns The wrapped child nodes.
448
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes | Node.childNodes}
449
+ */
450
+ get children() {
451
+ return _JJN.wrapAll(this.ref.childNodes);
452
+ }
415
453
  /**
416
454
  * Clones the Node.
417
455
  *
@@ -422,6 +460,29 @@ var JJN = class _JJN extends JJET {
422
460
  clone(deep) {
423
461
  return _JJN.wrap(this.ref.cloneNode(deep));
424
462
  }
463
+ /**
464
+ * Removes this node from its parent.
465
+ *
466
+ * @remarks
467
+ * If the node has no parent, this method does nothing.
468
+ *
469
+ * @example
470
+ * ```ts
471
+ * const el = JJHE.create('div')
472
+ * doc.body.addChild(el)
473
+ * el.rm()
474
+ * ```
475
+ *
476
+ * @returns This instance for chaining.
477
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild | Node.removeChild}
478
+ */
479
+ rm() {
480
+ const { parentNode } = this.ref;
481
+ if (parentNode) {
482
+ parentNode.removeChild(this.ref);
483
+ }
484
+ return this;
485
+ }
425
486
  /**
426
487
  * Creates a Text node from a string and appends it to this Node.
427
488
  *