@htmltools/hdom 0.1.4 → 0.1.6

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/hdom.d.ts CHANGED
@@ -11,6 +11,11 @@ export class hdom {
11
11
  * @returns {Element}
12
12
  */
13
13
  static addEventListener(e: string | Element, type: string, fn: (arg0: Event) => void): Element;
14
+ /**
15
+ * @param {Element} parent
16
+ * @param {string} str
17
+ */
18
+ static appendTextValue(parent: Element, str: string): void;
14
19
  /**
15
20
  * @param {string|HTMLElement} e
16
21
  */
@@ -163,10 +168,10 @@ export class hdom {
163
168
  */
164
169
  static setFocusTo(e: string | HTMLElement): void;
165
170
  /**
166
- * @param {string|HTMLElement} e
171
+ * @param {string|HTMLElement|RadioNodeList} e
167
172
  * @param {string|number} value
168
173
  */
169
- static setFormElementValue(e: string | HTMLElement, value: string | number): void;
174
+ static setFormElementValue(e: string | HTMLElement | RadioNodeList, value: string | number): void;
170
175
  /**
171
176
  * @param {string|Element} e
172
177
  * @param {string} text
package/lib/hdom.js CHANGED
@@ -22,6 +22,14 @@ export class hdom {
22
22
  return elem;
23
23
  }
24
24
 
25
+ /**
26
+ * @param {Element} parent
27
+ * @param {string} str
28
+ */
29
+ static appendTextValue(parent, str) {
30
+ parent.appendChild(document.createTextNode(str));
31
+ }
32
+
25
33
  /**
26
34
  * @param {string|HTMLElement} e
27
35
  */
@@ -355,15 +363,16 @@ export class hdom {
355
363
  }
356
364
 
357
365
  /**
358
- * @param {string|HTMLElement} e
366
+ * @param {string|HTMLElement|RadioNodeList} e
359
367
  * @param {string|number} value
360
368
  */
361
369
  static setFormElementValue(e, value) {
362
- const elem = this.getElement(e);
370
+ const elem = typeof e === "string" ? this.getElement(e) : e;
363
371
  if (
364
372
  elem instanceof HTMLInputElement ||
365
373
  elem instanceof HTMLTextAreaElement ||
366
- elem instanceof HTMLSelectElement
374
+ elem instanceof HTMLSelectElement ||
375
+ elem instanceof RadioNodeList
367
376
  ) {
368
377
  elem.value = value.toString();
369
378
  } else if (elem instanceof HTMLElement) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmltools/hdom",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Tools to interact with the HTML DOM.",
5
5
  "license": "MIT",
6
6
  "repository": {