tiny-essentials 1.22.6 → 1.22.7

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.
@@ -20,6 +20,12 @@ const {
20
20
  * @typedef {TinyHtml<ConstructorElValues>} TinyHtmlAny
21
21
  */
22
22
 
23
+ /**
24
+ * Represents the valid values that can be appended to a TinyNode.
25
+ *
26
+ * @typedef {TinyNode | TinyNode[] | string | false | null | undefined} AppendCheckerValues
27
+ */
28
+
23
29
  /**
24
30
  * Callback function used for hover events.
25
31
  * @callback HoverEventCallback
@@ -2142,13 +2148,19 @@ class TinyHtml {
2142
2148
  /**
2143
2149
  * Normalize and validate nodes before DOM insertion.
2144
2150
  * Converts TinyNode-like structures or strings into DOM-compatible nodes.
2145
- * @type {(where: string, ...nodes: (TinyNode | TinyNode[] | string)[]) => (Node | string)[]}
2151
+ * @type {(where: string, ...nodes: AppendCheckerValues[]) => (Node | string)[]}
2146
2152
  * @readonly
2147
2153
  */
2148
2154
  static _appendChecker(where, ...nodes) {
2149
2155
  const results = [];
2150
2156
  const nds = [...nodes];
2151
2157
  for (const index in nds) {
2158
+ if (
2159
+ typeof nds[index] === 'undefined' ||
2160
+ nds[index] === null ||
2161
+ nds[index] === false
2162
+ )
2163
+ continue;
2152
2164
  if (typeof nds[index] !== 'string') {
2153
2165
  results.push(TinyHtml._preNodeElem(nds[index], where));
2154
2166
  } else results.push(nds[index]);
@@ -2161,7 +2173,7 @@ class TinyHtml {
2161
2173
  *
2162
2174
  * @template {TinyElement} T
2163
2175
  * @param {T} el - The target element(s) to receive children.
2164
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
2176
+ * @param {...AppendCheckerValues} children - The child elements or text to append.
2165
2177
  * @returns {T}
2166
2178
  */
2167
2179
  static append(el, ...children) {
@@ -2173,7 +2185,7 @@ class TinyHtml {
2173
2185
  /**
2174
2186
  * Appends child elements or strings to the end of the target element(s).
2175
2187
  *
2176
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
2188
+ * @param {...AppendCheckerValues} children - The child elements or text to append.
2177
2189
  * @returns {this}
2178
2190
  */
2179
2191
  append(...children) {
@@ -2185,7 +2197,7 @@ class TinyHtml {
2185
2197
  *
2186
2198
  * @template {TinyElement} T
2187
2199
  * @param {T} el - The target element(s) to receive children.
2188
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
2200
+ * @param {...AppendCheckerValues} children - The child elements or text to prepend.
2189
2201
  * @returns {T}
2190
2202
  */
2191
2203
  static prepend(el, ...children) {
@@ -2197,7 +2209,7 @@ class TinyHtml {
2197
2209
  /**
2198
2210
  * Prepends child elements or strings to the beginning of the target element(s).
2199
2211
  *
2200
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
2212
+ * @param {...AppendCheckerValues} children - The child elements or text to prepend.
2201
2213
  * @returns {this}
2202
2214
  */
2203
2215
  prepend(...children) {
@@ -2209,7 +2221,7 @@ class TinyHtml {
2209
2221
  *
2210
2222
  * @template {TinyElement} T
2211
2223
  * @param {T} el - The target element(s) before which new content is inserted.
2212
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
2224
+ * @param {...AppendCheckerValues} children - Elements or text to insert before the target.
2213
2225
  * @returns {T}
2214
2226
  */
2215
2227
  static before(el, ...children) {
@@ -2221,7 +2233,7 @@ class TinyHtml {
2221
2233
  /**
2222
2234
  * Inserts elements or strings immediately before the target element(s) in the DOM.
2223
2235
  *
2224
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
2236
+ * @param {...AppendCheckerValues} children - Elements or text to insert before the target.
2225
2237
  * @returns {this}
2226
2238
  */
2227
2239
  before(...children) {
@@ -2233,7 +2245,7 @@ class TinyHtml {
2233
2245
  *
2234
2246
  * @template {TinyElement} T
2235
2247
  * @param {T} el - The target element(s) after which new content is inserted.
2236
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
2248
+ * @param {...AppendCheckerValues} children - Elements or text to insert after the target.
2237
2249
  * @returns {T}
2238
2250
  */
2239
2251
  static after(el, ...children) {
@@ -2245,7 +2257,7 @@ class TinyHtml {
2245
2257
  /**
2246
2258
  * Inserts elements or strings immediately after the target element(s) in the DOM.
2247
2259
  *
2248
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
2260
+ * @param {...AppendCheckerValues} children - Elements or text to insert after the target.
2249
2261
  * @returns {this}
2250
2262
  */
2251
2263
  after(...children) {
@@ -2257,7 +2269,7 @@ class TinyHtml {
2257
2269
  *
2258
2270
  * @template {TinyElement} T
2259
2271
  * @param {T} el - The element(s) to be replaced.
2260
- * @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
2272
+ * @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
2261
2273
  * @returns {T}
2262
2274
  */
2263
2275
  static replaceWith(el, ...newNodes) {
@@ -2269,7 +2281,7 @@ class TinyHtml {
2269
2281
  /**
2270
2282
  * Replaces the target element(s) in the DOM with new elements or text.
2271
2283
  *
2272
- * @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
2284
+ * @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
2273
2285
  * @returns {this}
2274
2286
  */
2275
2287
  replaceWith(...newNodes) {
@@ -3,6 +3,10 @@ export default TinyHtml;
3
3
  * Represents a TinyHtml instance with any constructor element values.
4
4
  */
5
5
  export type TinyHtmlAny = TinyHtml<ConstructorElValues>;
6
+ /**
7
+ * Represents the valid values that can be appended to a TinyNode.
8
+ */
9
+ export type AppendCheckerValues = TinyNode | TinyNode[] | string | false | null | undefined;
6
10
  /**
7
11
  * Callback function used for hover events.
8
12
  */
@@ -275,7 +279,55 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
275
279
  areElsCollPerfTop: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
276
280
  areElsCollPerfBottom: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
277
281
  areElsCollPerfLeft: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
278
- areElsCollPerfRight: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
282
+ areElsCollPerfRight: (rect1: TinyCollision.ObjRect,
283
+ /**
284
+ * Represents a value that can be either a DOM Element, or the document object.
285
+ * Useful for functions that operate generically on measurable targets.
286
+ *
287
+ * @typedef {Element|Document} ElementWithDoc
288
+ */
289
+ /**
290
+ * A parameter type used for filtering or matching elements.
291
+ * It can be:
292
+ * - A string (CSS selector),
293
+ * - A raw DOM element,
294
+ * - An array of raw DOM elements,
295
+ * - A filtering function that receives an index and element,
296
+ * and returns true if it matches.
297
+ *
298
+ * @typedef {string|Element|Element[]|((index: number, el: Element) => boolean)} WinnowRequest
299
+ */
300
+ /**
301
+ * Elements accepted as constructor values for TinyHtml.
302
+ * These include common DOM elements and root containers.
303
+ *
304
+ * @typedef {Window|Element|Document|Text} ConstructorElValues
305
+ */
306
+ /**
307
+ * Options passed to `addEventListener` or `removeEventListener`.
308
+ * Can be a boolean or an object of type `AddEventListenerOptions`.
309
+ *
310
+ * @typedef {boolean|AddEventListenerOptions} EventRegistryOptions
311
+ */
312
+ /**
313
+ * Structure describing a registered event callback and its options.
314
+ *
315
+ * @typedef {Object} EventRegistryItem
316
+ * @property {EventListenerOrEventListenerObject|null} handler - The function to be executed when the event is triggered.
317
+ * @property {EventRegistryOptions} [options] - Optional configuration passed to the listener.
318
+ */
319
+ /**
320
+ * Maps event names (e.g., `"click"`, `"keydown"`) to a list of registered handlers and options.
321
+ *
322
+ * @typedef {Record<string, EventRegistryItem[]>} EventRegistryList
323
+ */
324
+ /**
325
+ * WeakMap storing all event listeners per element.
326
+ * Each element has a registry mapping event names to their handler lists.
327
+ *
328
+ * @type {WeakMap<ConstructorElValues|EventTarget, EventRegistryList>}
329
+ */
330
+ rect2: TinyCollision.ObjRect) => boolean;
279
331
  areElsColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
280
332
  areElsPerfColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
281
333
  getElsColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => string | null;
@@ -969,52 +1021,52 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
969
1021
  * @returns {Node[]}
970
1022
  */
971
1023
  static clone(el: TinyNode | TinyNode[], deep?: boolean): Node[];
972
- static readonly _appendChecker(where: string, ...nodes: (TinyNode | TinyNode[] | string)[]): (Node | string)[];
1024
+ static readonly _appendChecker(where: string, ...nodes: AppendCheckerValues[]): (Node | string)[];
973
1025
  /**
974
1026
  * Appends child elements or strings to the end of the target element(s).
975
1027
  *
976
1028
  * @template {TinyElement} T
977
1029
  * @param {T} el - The target element(s) to receive children.
978
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
1030
+ * @param {...AppendCheckerValues} children - The child elements or text to append.
979
1031
  * @returns {T}
980
1032
  */
981
- static append<T extends TinyElement>(el: T, ...children: (TinyNode | TinyNode[] | string)[]): T;
1033
+ static append<T extends TinyElement>(el: T, ...children: AppendCheckerValues[]): T;
982
1034
  /**
983
1035
  * Prepends child elements or strings to the beginning of the target element(s).
984
1036
  *
985
1037
  * @template {TinyElement} T
986
1038
  * @param {T} el - The target element(s) to receive children.
987
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
1039
+ * @param {...AppendCheckerValues} children - The child elements or text to prepend.
988
1040
  * @returns {T}
989
1041
  */
990
- static prepend<T extends TinyElement>(el: T, ...children: (TinyNode | TinyNode[] | string)[]): T;
1042
+ static prepend<T extends TinyElement>(el: T, ...children: AppendCheckerValues[]): T;
991
1043
  /**
992
1044
  * Inserts elements or strings immediately before the target element(s) in the DOM.
993
1045
  *
994
1046
  * @template {TinyElement} T
995
1047
  * @param {T} el - The target element(s) before which new content is inserted.
996
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
1048
+ * @param {...AppendCheckerValues} children - Elements or text to insert before the target.
997
1049
  * @returns {T}
998
1050
  */
999
- static before<T extends TinyElement>(el: T, ...children: (TinyNode | TinyNode[] | string)[]): T;
1051
+ static before<T extends TinyElement>(el: T, ...children: AppendCheckerValues[]): T;
1000
1052
  /**
1001
1053
  * Inserts elements or strings immediately after the target element(s) in the DOM.
1002
1054
  *
1003
1055
  * @template {TinyElement} T
1004
1056
  * @param {T} el - The target element(s) after which new content is inserted.
1005
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
1057
+ * @param {...AppendCheckerValues} children - Elements or text to insert after the target.
1006
1058
  * @returns {T}
1007
1059
  */
1008
- static after<T extends TinyElement>(el: T, ...children: (TinyNode | TinyNode[] | string)[]): T;
1060
+ static after<T extends TinyElement>(el: T, ...children: AppendCheckerValues[]): T;
1009
1061
  /**
1010
1062
  * Replaces the target element(s) in the DOM with new elements or text.
1011
1063
  *
1012
1064
  * @template {TinyElement} T
1013
1065
  * @param {T} el - The element(s) to be replaced.
1014
- * @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
1066
+ * @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
1015
1067
  * @returns {T}
1016
1068
  */
1017
- static replaceWith<T extends TinyElement>(el: T, ...newNodes: (TinyNode | TinyNode[] | string)[]): T;
1069
+ static replaceWith<T extends TinyElement>(el: T, ...newNodes: AppendCheckerValues[]): T;
1018
1070
  /**
1019
1071
  * Appends the given element(s) to each target element in sequence.
1020
1072
  *
@@ -2944,38 +2996,38 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
2944
2996
  /**
2945
2997
  * Appends child elements or strings to the end of the target element(s).
2946
2998
  *
2947
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
2999
+ * @param {...AppendCheckerValues} children - The child elements or text to append.
2948
3000
  * @returns {this}
2949
3001
  */
2950
- append(...children: (TinyNode | TinyNode[] | string)[]): this;
3002
+ append(...children: AppendCheckerValues[]): this;
2951
3003
  /**
2952
3004
  * Prepends child elements or strings to the beginning of the target element(s).
2953
3005
  *
2954
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
3006
+ * @param {...AppendCheckerValues} children - The child elements or text to prepend.
2955
3007
  * @returns {this}
2956
3008
  */
2957
- prepend(...children: (TinyNode | TinyNode[] | string)[]): this;
3009
+ prepend(...children: AppendCheckerValues[]): this;
2958
3010
  /**
2959
3011
  * Inserts elements or strings immediately before the target element(s) in the DOM.
2960
3012
  *
2961
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
3013
+ * @param {...AppendCheckerValues} children - Elements or text to insert before the target.
2962
3014
  * @returns {this}
2963
3015
  */
2964
- before(...children: (TinyNode | TinyNode[] | string)[]): this;
3016
+ before(...children: AppendCheckerValues[]): this;
2965
3017
  /**
2966
3018
  * Inserts elements or strings immediately after the target element(s) in the DOM.
2967
3019
  *
2968
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
3020
+ * @param {...AppendCheckerValues} children - Elements or text to insert after the target.
2969
3021
  * @returns {this}
2970
3022
  */
2971
- after(...children: (TinyNode | TinyNode[] | string)[]): this;
3023
+ after(...children: AppendCheckerValues[]): this;
2972
3024
  /**
2973
3025
  * Replaces the target element(s) in the DOM with new elements or text.
2974
3026
  *
2975
- * @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
3027
+ * @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
2976
3028
  * @returns {this}
2977
3029
  */
2978
- replaceWith(...newNodes: (TinyNode | TinyNode[] | string)[]): this;
3030
+ replaceWith(...newNodes: AppendCheckerValues[]): this;
2979
3031
  /**
2980
3032
  * Appends the given element(s) to each target element in sequence.
2981
3033
  *
@@ -8,6 +8,11 @@ const { areElsColliding, areElsPerfColliding, areElsCollTop, areElsCollBottom, a
8
8
  * Represents a TinyHtml instance with any constructor element values.
9
9
  * @typedef {TinyHtml<ConstructorElValues>} TinyHtmlAny
10
10
  */
11
+ /**
12
+ * Represents the valid values that can be appended to a TinyNode.
13
+ *
14
+ * @typedef {TinyNode | TinyNode[] | string | false | null | undefined} AppendCheckerValues
15
+ */
11
16
  /**
12
17
  * Callback function used for hover events.
13
18
  * @callback HoverEventCallback
@@ -1868,13 +1873,17 @@ class TinyHtml {
1868
1873
  /**
1869
1874
  * Normalize and validate nodes before DOM insertion.
1870
1875
  * Converts TinyNode-like structures or strings into DOM-compatible nodes.
1871
- * @type {(where: string, ...nodes: (TinyNode | TinyNode[] | string)[]) => (Node | string)[]}
1876
+ * @type {(where: string, ...nodes: AppendCheckerValues[]) => (Node | string)[]}
1872
1877
  * @readonly
1873
1878
  */
1874
1879
  static _appendChecker(where, ...nodes) {
1875
1880
  const results = [];
1876
1881
  const nds = [...nodes];
1877
1882
  for (const index in nds) {
1883
+ if (typeof nds[index] === 'undefined' ||
1884
+ nds[index] === null ||
1885
+ nds[index] === false)
1886
+ continue;
1878
1887
  if (typeof nds[index] !== 'string') {
1879
1888
  results.push(TinyHtml._preNodeElem(nds[index], where));
1880
1889
  }
@@ -1888,7 +1897,7 @@ class TinyHtml {
1888
1897
  *
1889
1898
  * @template {TinyElement} T
1890
1899
  * @param {T} el - The target element(s) to receive children.
1891
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
1900
+ * @param {...AppendCheckerValues} children - The child elements or text to append.
1892
1901
  * @returns {T}
1893
1902
  */
1894
1903
  static append(el, ...children) {
@@ -1899,7 +1908,7 @@ class TinyHtml {
1899
1908
  /**
1900
1909
  * Appends child elements or strings to the end of the target element(s).
1901
1910
  *
1902
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
1911
+ * @param {...AppendCheckerValues} children - The child elements or text to append.
1903
1912
  * @returns {this}
1904
1913
  */
1905
1914
  append(...children) {
@@ -1910,7 +1919,7 @@ class TinyHtml {
1910
1919
  *
1911
1920
  * @template {TinyElement} T
1912
1921
  * @param {T} el - The target element(s) to receive children.
1913
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
1922
+ * @param {...AppendCheckerValues} children - The child elements or text to prepend.
1914
1923
  * @returns {T}
1915
1924
  */
1916
1925
  static prepend(el, ...children) {
@@ -1921,7 +1930,7 @@ class TinyHtml {
1921
1930
  /**
1922
1931
  * Prepends child elements or strings to the beginning of the target element(s).
1923
1932
  *
1924
- * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
1933
+ * @param {...AppendCheckerValues} children - The child elements or text to prepend.
1925
1934
  * @returns {this}
1926
1935
  */
1927
1936
  prepend(...children) {
@@ -1932,7 +1941,7 @@ class TinyHtml {
1932
1941
  *
1933
1942
  * @template {TinyElement} T
1934
1943
  * @param {T} el - The target element(s) before which new content is inserted.
1935
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
1944
+ * @param {...AppendCheckerValues} children - Elements or text to insert before the target.
1936
1945
  * @returns {T}
1937
1946
  */
1938
1947
  static before(el, ...children) {
@@ -1943,7 +1952,7 @@ class TinyHtml {
1943
1952
  /**
1944
1953
  * Inserts elements or strings immediately before the target element(s) in the DOM.
1945
1954
  *
1946
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
1955
+ * @param {...AppendCheckerValues} children - Elements or text to insert before the target.
1947
1956
  * @returns {this}
1948
1957
  */
1949
1958
  before(...children) {
@@ -1954,7 +1963,7 @@ class TinyHtml {
1954
1963
  *
1955
1964
  * @template {TinyElement} T
1956
1965
  * @param {T} el - The target element(s) after which new content is inserted.
1957
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
1966
+ * @param {...AppendCheckerValues} children - Elements or text to insert after the target.
1958
1967
  * @returns {T}
1959
1968
  */
1960
1969
  static after(el, ...children) {
@@ -1965,7 +1974,7 @@ class TinyHtml {
1965
1974
  /**
1966
1975
  * Inserts elements or strings immediately after the target element(s) in the DOM.
1967
1976
  *
1968
- * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
1977
+ * @param {...AppendCheckerValues} children - Elements or text to insert after the target.
1969
1978
  * @returns {this}
1970
1979
  */
1971
1980
  after(...children) {
@@ -1976,7 +1985,7 @@ class TinyHtml {
1976
1985
  *
1977
1986
  * @template {TinyElement} T
1978
1987
  * @param {T} el - The element(s) to be replaced.
1979
- * @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
1988
+ * @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
1980
1989
  * @returns {T}
1981
1990
  */
1982
1991
  static replaceWith(el, ...newNodes) {
@@ -1987,7 +1996,7 @@ class TinyHtml {
1987
1996
  /**
1988
1997
  * Replaces the target element(s) in the DOM with new elements or text.
1989
1998
  *
1990
- * @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
1999
+ * @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
1991
2000
  * @returns {this}
1992
2001
  */
1993
2002
  replaceWith(...newNodes) {
@@ -19,6 +19,7 @@ This design keeps your code concise while maintaining clarity and control over t
19
19
  ## 📑 Table of Contents
20
20
 
21
21
  - [🧩 Type Definitions – Core Building Blocks](#-type-definitions--core-building-blocks)
22
+ - [🔍 Element Debugging System](#-element-debugging-system)
22
23
  - [🔨 Element Creation](#-element-creation)
23
24
  - [🔎 Static DOM Selectors](#-static-dom-selectors)
24
25
  - [🔍 Element Observer](#-element-observer)
@@ -525,6 +526,110 @@ const __elementCurrentAnimation = new WeakMap();
525
526
 
526
527
  ---
527
528
 
529
+ ## 🔍 Element Debugging System
530
+
531
+ TinyHtml includes a built-in **element debugging system** to help developers identify issues with elements during validation, construction, or event handling.
532
+
533
+ This feature is **disabled by default** and can be toggled on or off.
534
+
535
+ ---
536
+
537
+ ### ⚙️ Enabling Debug Mode
538
+
539
+ ```js
540
+ TinyHtml.elemDebug = true; // Enable
541
+ TinyHtml.elemDebug = false; // Disable
542
+ ```
543
+
544
+ #### API
545
+
546
+ * **`TinyHtml.elemDebug` (boolean)**
547
+ Controls whether TinyHtml emits detailed debug output to the console.
548
+
549
+ * **Getter**
550
+
551
+ ```js
552
+ TinyHtml.elemDebug; // Returns true or false
553
+ ```
554
+
555
+ * **Setter**
556
+
557
+ ```js
558
+ TinyHtml.elemDebug = true; // Enable debug logs
559
+ TinyHtml.elemDebug = false; // Disable debug logs
560
+ ```
561
+
562
+ 🚨 Throws `TypeError` if the value is not a boolean.
563
+
564
+ ---
565
+
566
+ ### 🛠 Debugging Invalid Elements
567
+
568
+ When debug mode is enabled, TinyHtml will log structured information whenever an invalid or unexpected element is passed to its internal operations.
569
+
570
+ This is done through the internal method:
571
+
572
+ ```js
573
+ TinyHtml._debugElemError(elems, elem);
574
+ ```
575
+
576
+ #### Parameters
577
+
578
+ * **`elems`** → An array of elements (`ConstructorElValues | EventTarget | TinyElement | null`) involved in the operation.
579
+ * **`elem`** *(optional)* → The specific element that triggered the error.
580
+
581
+ #### Output Includes
582
+
583
+ * ❌ **Error header** in the console
584
+ * 🧭 **Stack trace** (with `console.trace` or captured stack)
585
+ * 📊 **`console.table`** showing:
586
+
587
+ * Index
588
+ * `typeof`
589
+ * Constructor name
590
+ * Summary (DOM tag, ID, class, or nodeType)
591
+ * The raw value
592
+ * 🎯 **Problematic element** highlighted separately via `console.dir`
593
+
594
+ ---
595
+
596
+ ### 📋 Example Output
597
+
598
+ When debug mode is enabled and an invalid element is detected, you may see something like this:
599
+
600
+ ```
601
+ [TinyHtml Debug] Element validation error
602
+ Error: [TinyHtml Debug] Element validation error
603
+ at TinyHtml._debugElemError (...)
604
+ at ...
605
+ ```
606
+
607
+ Followed by a **console.table**:
608
+
609
+ | index | typeOf | constructor | summary | value |
610
+ | ----- | ------ | ----------- | ------------------ | ------------- |
611
+ | 0 | object | TinyElement | div#main.container | TinyElement{} |
612
+ | 1 | string | primitive | | "invalid" |
613
+ | 2 | null | null | | null |
614
+
615
+ And a detailed log of the problematic element:
616
+
617
+ ```
618
+ [TinyHtml Debug] Problematic element:
619
+ <div id="main" class="container">...</div>
620
+ ```
621
+
622
+ ---
623
+
624
+ ### ✅ Summary
625
+
626
+ * 🔧 Enable debug with `TinyHtml.elemDebug = true;`
627
+ * 🐞 Detailed errors are shown only when debug mode is on
628
+ * 📊 Uses `console.table`, `console.error`, and `console.dir` for clarity
629
+ * 🚀 Zero runtime overhead when disabled
630
+
631
+ ---
632
+
528
633
  ## 🔨 Element Creation
529
634
 
530
635
  ### `TinyHtml.createFrom(tagName, attrs?)`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-essentials",
3
- "version": "1.22.6",
3
+ "version": "1.22.7",
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",