@zyrab/domo 1.2.0 → 1.3.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/package.json +1 -1
- package/src/builder.js +4 -1
- package/src/children.js +1 -5
- package/src/events.js +2 -1
package/package.json
CHANGED
package/src/builder.js
CHANGED
|
@@ -32,9 +32,12 @@ class Builder {
|
|
|
32
32
|
|
|
33
33
|
if (cls) attrs.push(`class="${cls}"`);
|
|
34
34
|
if (css) attrs.push(`style="${css}"`);
|
|
35
|
+
const escapeHTML = (str) => String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
35
36
|
|
|
36
37
|
const attrStr = attrs.concat(data).join(" ");
|
|
37
|
-
const children = this.element._child
|
|
38
|
+
const children = this.element._child
|
|
39
|
+
.map((c) => (typeof c === "string" ? escapeHTML(c) : c.build?.() || ""))
|
|
40
|
+
.join("");
|
|
38
41
|
|
|
39
42
|
return `<${tag}${attrStr ? " " + attrStr : ""}>${children}</${tag}>`;
|
|
40
43
|
}
|
package/src/children.js
CHANGED
|
@@ -10,10 +10,6 @@ class Children {
|
|
|
10
10
|
* a string for virtual children, or a Domo instance for virtual children.
|
|
11
11
|
*/
|
|
12
12
|
_handleElementInstance(element) {
|
|
13
|
-
// Check if Domo class exists (it's imported in main.domo.js for final class)
|
|
14
|
-
// To avoid circular dependency in JSDoc parsing, we'll check runtime type.
|
|
15
|
-
// For JSDoc type checking, we assume Domo is available in the context of main.domo.js.
|
|
16
|
-
// @ts-ignore - Ignore potential 'Domo is not defined' for JSDoc tool
|
|
17
13
|
if (element instanceof DomoClass) return element.build();
|
|
18
14
|
|
|
19
15
|
if (element instanceof DocumentFragment) return element;
|
|
@@ -173,7 +169,7 @@ class Children {
|
|
|
173
169
|
if(condition) {
|
|
174
170
|
// @ts-ignore - Ignore potential 'Domo is not defined' for JSDoc tool
|
|
175
171
|
if (!condition) {
|
|
176
|
-
return new
|
|
172
|
+
return new DomoClass("if")
|
|
177
173
|
.attr({
|
|
178
174
|
hidden: true,
|
|
179
175
|
})
|
package/src/events.js
CHANGED
|
@@ -35,7 +35,8 @@ class Events {
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
on(eventMapOrName, callback, options = {}) {
|
|
38
|
-
if (
|
|
38
|
+
if (!eventMapOrName || !callback) return this;
|
|
39
|
+
if (this._virtual) {
|
|
39
40
|
if (options.ssg === false) return this;
|
|
40
41
|
const elId = this.element._attr?.id;
|
|
41
42
|
if (!elId) throw new Error(`[Domo.on] .id() must be called before .on(...) in SSG mode`);
|