phane-tech-dom-utils 1.0.3 โ 1.0.4
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 +322 -322
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,322 +1,322 @@
|
|
|
1
|
-
# ๐ฆ Kotipalli Phaneendra Kumar - Array Utilities
|
|
2
|
-
|
|
3
|
-
A lightweight, safe, and predictable **DOM utility module** that simplifies common DOM operations with **strict validation**, **consistent return values**, and **clean JSDoc documentation**.
|
|
4
|
-
|
|
5
|
-
Designed specifically for **browser environments**, this module helps you work confidently with elements, attributes, classes, styles, events, and dynamic DOM creation without unexpected runtime errors.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## โจ Highlights
|
|
10
|
-
|
|
11
|
-
- ๐งฑ Safe DOM selectors with validation
|
|
12
|
-
- ๐ท๏ธ Attribute helpers (get / set / remove)
|
|
13
|
-
- ๐งฉ Class utilities (add / remove / toggle / check)
|
|
14
|
-
- ๐จ Style helpers (single & multiple styles)
|
|
15
|
-
- ๐งฉ Dynamic element creation & DOM insertion
|
|
16
|
-
- ๐ง Event listener helpers
|
|
17
|
-
- โญ Tab title & favicon utilities
|
|
18
|
-
- ๐ Fully documented using JSDoc
|
|
19
|
-
- โก Predictable return values (`undefined` for invalid input)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## ๐ฆ Installation
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
npm install phane-
|
|
27
|
-
```
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## ๐ Import
|
|
31
|
-
|
|
32
|
-
```js
|
|
33
|
-
import {
|
|
34
|
-
getElementById,
|
|
35
|
-
getElementsByClassName,
|
|
36
|
-
getElementsByTagName,
|
|
37
|
-
setTabTitle,
|
|
38
|
-
getTabTitle,
|
|
39
|
-
setFavicon,
|
|
40
|
-
getFavicon,
|
|
41
|
-
setTextContent,
|
|
42
|
-
setHTMLContent,
|
|
43
|
-
setAttribute,
|
|
44
|
-
getAttribute,
|
|
45
|
-
removeAttribute,
|
|
46
|
-
hasClass,
|
|
47
|
-
addClass,
|
|
48
|
-
removeClass,
|
|
49
|
-
toggleClass,
|
|
50
|
-
setStyle,
|
|
51
|
-
setStyles,
|
|
52
|
-
createDynamicElement,
|
|
53
|
-
appendDynamicTag,
|
|
54
|
-
removeElement,
|
|
55
|
-
addEventListenerHelper,
|
|
56
|
-
removeEventListenerHelper,
|
|
57
|
-
onElementLoad,
|
|
58
|
-
setDataId
|
|
59
|
-
} from "phane-
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## ๐ API Reference
|
|
65
|
-
|
|
66
|
-
### ๐ getElementById(id)
|
|
67
|
-
|
|
68
|
-
Safely returns a DOM element by its ID.
|
|
69
|
-
|
|
70
|
-
```js
|
|
71
|
-
getElementById("header"); // HTMLElement | null
|
|
72
|
-
getElementById("unknown"); // null
|
|
73
|
-
getElementById(""); // undefined
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
### ๐ getElementsByClassName(className)
|
|
79
|
-
|
|
80
|
-
Returns a live HTMLCollection of elements.
|
|
81
|
-
|
|
82
|
-
```js
|
|
83
|
-
getElementsByClassName("card"); // HTMLCollection
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
### ๐ getElementsByTagName(tagName)
|
|
89
|
-
|
|
90
|
-
Returns a live HTMLCollection of elements.
|
|
91
|
-
|
|
92
|
-
```js
|
|
93
|
-
getElementsByTagName("div"); // HTMLCollection
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
### ๐ท๏ธ setTabTitle(title)
|
|
99
|
-
|
|
100
|
-
Sets the browser tab title.
|
|
101
|
-
|
|
102
|
-
```js
|
|
103
|
-
setTabTitle("Home"); // "Home"
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
### โญ getTabTitle()
|
|
109
|
-
|
|
110
|
-
Returns the current tab title.
|
|
111
|
-
|
|
112
|
-
```js
|
|
113
|
-
getTabTitle(); // "Home"
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
### โญ setFavicon(url)
|
|
119
|
-
|
|
120
|
-
Sets or updates the browser favicon.
|
|
121
|
-
|
|
122
|
-
```js
|
|
123
|
-
setFavicon("/favicon.ico");
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
### โญ getFavicon()
|
|
129
|
-
|
|
130
|
-
Returns the current favicon URL if available.
|
|
131
|
-
|
|
132
|
-
```js
|
|
133
|
-
getFavicon(); // string | undefined
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
### โ๏ธ setTextContent(element, text)
|
|
139
|
-
|
|
140
|
-
Safely sets innerText on an element.
|
|
141
|
-
|
|
142
|
-
```js
|
|
143
|
-
setTextContent(el, "Hello World");
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
### โ๏ธ setHTMLContent(element, html)
|
|
149
|
-
|
|
150
|
-
Safely sets innerHTML on an element.
|
|
151
|
-
```js
|
|
152
|
-
setHTMLContent(el, "<b>Hello</b>");
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
### ๐งฑ setAttribute(element, name, value)
|
|
158
|
-
|
|
159
|
-
Adds or updates an attribute.
|
|
160
|
-
|
|
161
|
-
```js
|
|
162
|
-
setAttribute(el, "data-id", "123");
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
### ๐งฑ getAttribute(element, name)
|
|
168
|
-
|
|
169
|
-
Gets an attribute value.
|
|
170
|
-
|
|
171
|
-
```js
|
|
172
|
-
getAttribute(el, "data-id"); // "123"
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
### ๐งฑ removeAttribute(element, name)
|
|
178
|
-
|
|
179
|
-
Removes an attribute.
|
|
180
|
-
|
|
181
|
-
```js
|
|
182
|
-
removeAttribute(el, "disabled");
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
### ๐งฉ hasClass(element, className)
|
|
188
|
-
|
|
189
|
-
Checks if a class exists on an element.
|
|
190
|
-
|
|
191
|
-
```js
|
|
192
|
-
hasClass(el, "active"); // true | false
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
---
|
|
196
|
-
|
|
197
|
-
### ๐งฉ addClass / removeClass / toggleClass
|
|
198
|
-
|
|
199
|
-
Manages element classes safely.
|
|
200
|
-
|
|
201
|
-
```js
|
|
202
|
-
addClass(el, "active");
|
|
203
|
-
removeClass(el, "active");
|
|
204
|
-
toggleClass(el, "active");
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
### ๐จ setStyle(element, property, value)
|
|
210
|
-
|
|
211
|
-
Sets a single CSS style.
|
|
212
|
-
|
|
213
|
-
```js
|
|
214
|
-
setStyle(el, "color", "red");
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
---
|
|
218
|
-
|
|
219
|
-
### ๐จ setStyles(element, styles)
|
|
220
|
-
|
|
221
|
-
Applies multiple CSS styles at once.
|
|
222
|
-
|
|
223
|
-
```js
|
|
224
|
-
setStyles(el, {
|
|
225
|
-
color: "red",
|
|
226
|
-
backgroundColor: "yellow"
|
|
227
|
-
});
|
|
228
|
-
```
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
### ๐งฉ createDynamicElement(tag, content?, props?)
|
|
232
|
-
|
|
233
|
-
Creates a DOM element dynamically.
|
|
234
|
-
|
|
235
|
-
```js
|
|
236
|
-
createDynamicElement("div", "Hello", {
|
|
237
|
-
id: "box",
|
|
238
|
-
className: "card"
|
|
239
|
-
});
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
---
|
|
243
|
-
|
|
244
|
-
### โ appendDynamicTag(child, parent?)
|
|
245
|
-
|
|
246
|
-
Appends an element to the DOM.
|
|
247
|
-
|
|
248
|
-
```js
|
|
249
|
-
appendDynamicTag(div);
|
|
250
|
-
appendDynamicTag(div, container);
|
|
251
|
-
```
|
|
252
|
-
---
|
|
253
|
-
|
|
254
|
-
### โ removeElement(child, parent?)
|
|
255
|
-
|
|
256
|
-
Removes an element from the DOM.
|
|
257
|
-
|
|
258
|
-
```js
|
|
259
|
-
removeElement(div);
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
---
|
|
263
|
-
|
|
264
|
-
### ๐ง addEventListenerHelper(el, type, handler)
|
|
265
|
-
|
|
266
|
-
Adds an event listener safely.
|
|
267
|
-
|
|
268
|
-
```js
|
|
269
|
-
addEventListenerHelper(btn, "click", handleClick);
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
### ๐ง removeEventListenerHelper(el, type, handler)
|
|
275
|
-
|
|
276
|
-
Removes an event listener safely.
|
|
277
|
-
|
|
278
|
-
```js
|
|
279
|
-
removeEventListenerHelper(btn, "click", handleClick);
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
---
|
|
283
|
-
|
|
284
|
-
### โณ onElementLoad(element?, handler)
|
|
285
|
-
|
|
286
|
-
Executes a handler when DOM or element is ready.
|
|
287
|
-
|
|
288
|
-
```js
|
|
289
|
-
onElementLoad(null, () => console.log("DOM Ready"));
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
---
|
|
294
|
-
|
|
295
|
-
### ๐ setDataId(element, value)
|
|
296
|
-
|
|
297
|
-
Sets data-id attribute.
|
|
298
|
-
|
|
299
|
-
```js
|
|
300
|
-
setDataId(el, "123");
|
|
301
|
-
```
|
|
302
|
-
---
|
|
303
|
-
|
|
304
|
-
## ๐งช Design Principles
|
|
305
|
-
|
|
306
|
-
- โ Invalid input โ undefined
|
|
307
|
-
- โ
Safe DOM access
|
|
308
|
-
- ๐ No unexpected mutations
|
|
309
|
-
- ๐ Predictable, documented behavior
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
## ๐ License
|
|
313
|
-
|
|
314
|
-
MIT
|
|
315
|
-
|
|
316
|
-
---
|
|
317
|
-
## ๐ Links
|
|
318
|
-
|
|
319
|
-
- **GitHub Repository:** https://github.com/phane-tech/phane-tech-dom-utilities
|
|
320
|
-
- **Demo / Documentation:** https://phane-tech.github.io/phane-tech-dom-utilities/module-DomHelpers.html
|
|
321
|
-
- **Unit Test Cases Reports:** https://phane-tech.github.io/phane-tech-dom-utilities/unit-test-report.html
|
|
322
|
-
|
|
1
|
+
# ๐ฆ Kotipalli Phaneendra Kumar - Array Utilities
|
|
2
|
+
|
|
3
|
+
A lightweight, safe, and predictable **DOM utility module** that simplifies common DOM operations with **strict validation**, **consistent return values**, and **clean JSDoc documentation**.
|
|
4
|
+
|
|
5
|
+
Designed specifically for **browser environments**, this module helps you work confidently with elements, attributes, classes, styles, events, and dynamic DOM creation without unexpected runtime errors.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## โจ Highlights
|
|
10
|
+
|
|
11
|
+
- ๐งฑ Safe DOM selectors with validation
|
|
12
|
+
- ๐ท๏ธ Attribute helpers (get / set / remove)
|
|
13
|
+
- ๐งฉ Class utilities (add / remove / toggle / check)
|
|
14
|
+
- ๐จ Style helpers (single & multiple styles)
|
|
15
|
+
- ๐งฉ Dynamic element creation & DOM insertion
|
|
16
|
+
- ๐ง Event listener helpers
|
|
17
|
+
- โญ Tab title & favicon utilities
|
|
18
|
+
- ๐ Fully documented using JSDoc
|
|
19
|
+
- โก Predictable return values (`undefined` for invalid input)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ๐ฆ Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install phane-tech-dom-utils
|
|
27
|
+
```
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## ๐ Import
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import {
|
|
34
|
+
getElementById,
|
|
35
|
+
getElementsByClassName,
|
|
36
|
+
getElementsByTagName,
|
|
37
|
+
setTabTitle,
|
|
38
|
+
getTabTitle,
|
|
39
|
+
setFavicon,
|
|
40
|
+
getFavicon,
|
|
41
|
+
setTextContent,
|
|
42
|
+
setHTMLContent,
|
|
43
|
+
setAttribute,
|
|
44
|
+
getAttribute,
|
|
45
|
+
removeAttribute,
|
|
46
|
+
hasClass,
|
|
47
|
+
addClass,
|
|
48
|
+
removeClass,
|
|
49
|
+
toggleClass,
|
|
50
|
+
setStyle,
|
|
51
|
+
setStyles,
|
|
52
|
+
createDynamicElement,
|
|
53
|
+
appendDynamicTag,
|
|
54
|
+
removeElement,
|
|
55
|
+
addEventListenerHelper,
|
|
56
|
+
removeEventListenerHelper,
|
|
57
|
+
onElementLoad,
|
|
58
|
+
setDataId
|
|
59
|
+
} from "phane-tech-dom-utils";
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## ๐ API Reference
|
|
65
|
+
|
|
66
|
+
### ๐ getElementById(id)
|
|
67
|
+
|
|
68
|
+
Safely returns a DOM element by its ID.
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
getElementById("header"); // HTMLElement | null
|
|
72
|
+
getElementById("unknown"); // null
|
|
73
|
+
getElementById(""); // undefined
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### ๐ getElementsByClassName(className)
|
|
79
|
+
|
|
80
|
+
Returns a live HTMLCollection of elements.
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
getElementsByClassName("card"); // HTMLCollection
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### ๐ getElementsByTagName(tagName)
|
|
89
|
+
|
|
90
|
+
Returns a live HTMLCollection of elements.
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
getElementsByTagName("div"); // HTMLCollection
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### ๐ท๏ธ setTabTitle(title)
|
|
99
|
+
|
|
100
|
+
Sets the browser tab title.
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
setTabTitle("Home"); // "Home"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### โญ getTabTitle()
|
|
109
|
+
|
|
110
|
+
Returns the current tab title.
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
getTabTitle(); // "Home"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### โญ setFavicon(url)
|
|
119
|
+
|
|
120
|
+
Sets or updates the browser favicon.
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
setFavicon("/favicon.ico");
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### โญ getFavicon()
|
|
129
|
+
|
|
130
|
+
Returns the current favicon URL if available.
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
getFavicon(); // string | undefined
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### โ๏ธ setTextContent(element, text)
|
|
139
|
+
|
|
140
|
+
Safely sets innerText on an element.
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
setTextContent(el, "Hello World");
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### โ๏ธ setHTMLContent(element, html)
|
|
149
|
+
|
|
150
|
+
Safely sets innerHTML on an element.
|
|
151
|
+
```js
|
|
152
|
+
setHTMLContent(el, "<b>Hello</b>");
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
### ๐งฑ setAttribute(element, name, value)
|
|
158
|
+
|
|
159
|
+
Adds or updates an attribute.
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
setAttribute(el, "data-id", "123");
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### ๐งฑ getAttribute(element, name)
|
|
168
|
+
|
|
169
|
+
Gets an attribute value.
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
getAttribute(el, "data-id"); // "123"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### ๐งฑ removeAttribute(element, name)
|
|
178
|
+
|
|
179
|
+
Removes an attribute.
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
removeAttribute(el, "disabled");
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
### ๐งฉ hasClass(element, className)
|
|
188
|
+
|
|
189
|
+
Checks if a class exists on an element.
|
|
190
|
+
|
|
191
|
+
```js
|
|
192
|
+
hasClass(el, "active"); // true | false
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### ๐งฉ addClass / removeClass / toggleClass
|
|
198
|
+
|
|
199
|
+
Manages element classes safely.
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
addClass(el, "active");
|
|
203
|
+
removeClass(el, "active");
|
|
204
|
+
toggleClass(el, "active");
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### ๐จ setStyle(element, property, value)
|
|
210
|
+
|
|
211
|
+
Sets a single CSS style.
|
|
212
|
+
|
|
213
|
+
```js
|
|
214
|
+
setStyle(el, "color", "red");
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
### ๐จ setStyles(element, styles)
|
|
220
|
+
|
|
221
|
+
Applies multiple CSS styles at once.
|
|
222
|
+
|
|
223
|
+
```js
|
|
224
|
+
setStyles(el, {
|
|
225
|
+
color: "red",
|
|
226
|
+
backgroundColor: "yellow"
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### ๐งฉ createDynamicElement(tag, content?, props?)
|
|
232
|
+
|
|
233
|
+
Creates a DOM element dynamically.
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
createDynamicElement("div", "Hello", {
|
|
237
|
+
id: "box",
|
|
238
|
+
className: "card"
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
### โ appendDynamicTag(child, parent?)
|
|
245
|
+
|
|
246
|
+
Appends an element to the DOM.
|
|
247
|
+
|
|
248
|
+
```js
|
|
249
|
+
appendDynamicTag(div);
|
|
250
|
+
appendDynamicTag(div, container);
|
|
251
|
+
```
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
### โ removeElement(child, parent?)
|
|
255
|
+
|
|
256
|
+
Removes an element from the DOM.
|
|
257
|
+
|
|
258
|
+
```js
|
|
259
|
+
removeElement(div);
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
### ๐ง addEventListenerHelper(el, type, handler)
|
|
265
|
+
|
|
266
|
+
Adds an event listener safely.
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
addEventListenerHelper(btn, "click", handleClick);
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
### ๐ง removeEventListenerHelper(el, type, handler)
|
|
275
|
+
|
|
276
|
+
Removes an event listener safely.
|
|
277
|
+
|
|
278
|
+
```js
|
|
279
|
+
removeEventListenerHelper(btn, "click", handleClick);
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### โณ onElementLoad(element?, handler)
|
|
285
|
+
|
|
286
|
+
Executes a handler when DOM or element is ready.
|
|
287
|
+
|
|
288
|
+
```js
|
|
289
|
+
onElementLoad(null, () => console.log("DOM Ready"));
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
### ๐ setDataId(element, value)
|
|
296
|
+
|
|
297
|
+
Sets data-id attribute.
|
|
298
|
+
|
|
299
|
+
```js
|
|
300
|
+
setDataId(el, "123");
|
|
301
|
+
```
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## ๐งช Design Principles
|
|
305
|
+
|
|
306
|
+
- โ Invalid input โ undefined
|
|
307
|
+
- โ
Safe DOM access
|
|
308
|
+
- ๐ No unexpected mutations
|
|
309
|
+
- ๐ Predictable, documented behavior
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
## ๐ License
|
|
313
|
+
|
|
314
|
+
MIT
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
## ๐ Links
|
|
318
|
+
|
|
319
|
+
- **GitHub Repository:** https://github.com/phane-tech/phane-tech-dom-utilities
|
|
320
|
+
- **Demo / Documentation:** https://phane-tech.github.io/phane-tech-dom-utilities/module-DomHelpers.html
|
|
321
|
+
- **Unit Test Cases Reports:** https://phane-tech.github.io/phane-tech-dom-utilities/unit-test-report.html
|
|
322
|
+
|