tiny-essentials 1.22.2 → 1.22.3

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.
@@ -6736,6 +6736,31 @@ class TinyHtml {
6736
6736
  return TinyHtml.toggleProp(this, name, force);
6737
6737
  }
6738
6738
 
6739
+ /**
6740
+ * Get properties on an element.
6741
+ *
6742
+ * @param {TinyHtmlElement} el - Target element.
6743
+ * @param {string} name - Property name.
6744
+ * @returns {any} - Property value if getting, otherwise `undefined`.
6745
+ */
6746
+ static prop(el, name) {
6747
+ if (typeof name !== 'string')
6748
+ throw new TypeError('Invalid arguments passed to prop(). Expected string for "name".');
6749
+ const elem = TinyHtml._preElem(el, 'attr');
6750
+ // @ts-ignore
6751
+ return elem[name];
6752
+ }
6753
+
6754
+ /**
6755
+ * Get properties on an element.
6756
+ *
6757
+ * @param {string} name - Property name.
6758
+ * @returns {any} - Property value if getting, otherwise `undefined`.
6759
+ */
6760
+ prop(name) {
6761
+ return TinyHtml.prop(this, name);
6762
+ }
6763
+
6739
6764
  /////////////////////////////////////////////////////
6740
6765
 
6741
6766
  // TITLE: Remove Element
@@ -2409,6 +2409,14 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
2409
2409
  * @returns {T}
2410
2410
  */
2411
2411
  static toggleProp<T extends TinyElement | TinyElement[]>(el: T, name: string | string[], force?: boolean): T;
2412
+ /**
2413
+ * Get properties on an element.
2414
+ *
2415
+ * @param {TinyHtmlElement} el - Target element.
2416
+ * @param {string} name - Property name.
2417
+ * @returns {any} - Property value if getting, otherwise `undefined`.
2418
+ */
2419
+ static prop(el: TinyHtmlElement, name: string): any;
2412
2420
  /**
2413
2421
  * Removes an element from the DOM.
2414
2422
  * @template {TinyElement|TinyElement[]} T
@@ -3554,6 +3562,13 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
3554
3562
  * @returns {this}
3555
3563
  */
3556
3564
  toggleProp(name: string | string[], force?: boolean): this;
3565
+ /**
3566
+ * Get properties on an element.
3567
+ *
3568
+ * @param {string} name - Property name.
3569
+ * @returns {any} - Property value if getting, otherwise `undefined`.
3570
+ */
3571
+ prop(name: string): any;
3557
3572
  /**
3558
3573
  * Removes the element from the DOM.
3559
3574
  * @returns {this}
@@ -6051,6 +6051,29 @@ class TinyHtml {
6051
6051
  toggleProp(name, force) {
6052
6052
  return TinyHtml.toggleProp(this, name, force);
6053
6053
  }
6054
+ /**
6055
+ * Get properties on an element.
6056
+ *
6057
+ * @param {TinyHtmlElement} el - Target element.
6058
+ * @param {string} name - Property name.
6059
+ * @returns {any} - Property value if getting, otherwise `undefined`.
6060
+ */
6061
+ static prop(el, name) {
6062
+ if (typeof name !== 'string')
6063
+ throw new TypeError('Invalid arguments passed to prop(). Expected string for "name".');
6064
+ const elem = TinyHtml._preElem(el, 'attr');
6065
+ // @ts-ignore
6066
+ return elem[name];
6067
+ }
6068
+ /**
6069
+ * Get properties on an element.
6070
+ *
6071
+ * @param {string} name - Property name.
6072
+ * @returns {any} - Property value if getting, otherwise `undefined`.
6073
+ */
6074
+ prop(name) {
6075
+ return TinyHtml.prop(this, name);
6076
+ }
6054
6077
  /////////////////////////////////////////////////////
6055
6078
  // TITLE: Remove Element
6056
6079
  /**
@@ -2081,11 +2081,12 @@ Safe and type-checked — throws if misuse is detected.
2081
2081
 
2082
2082
  ---
2083
2083
 
2084
- ### 🧲 `.hasProp()` / `.addProp()` / `.removeProp()` / `.toggleProp()`
2084
+ ### 🧲 `.hasProp()` / `.addProp()` / `.removeProp()` / `.toggleProp()` / `.prop()`
2085
2085
 
2086
2086
  Properties
2087
2087
 
2088
2088
  ```js
2089
+ element.prop('scrollHeight'); // get scrollHeight value
2089
2090
  element.hasProp("disabled"); // true/false
2090
2091
  element.addProp("checked"); // set true
2091
2092
  element.removeProp("checked"); // set false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-essentials",
3
- "version": "1.22.2",
3
+ "version": "1.22.3",
4
4
  "description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
5
5
  "scripts": {
6
6
  "test": "npm run test:mjs && npm run test:cjs && npm run test:js",