@domql/element 3.5.0 → 3.6.1
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 +19 -1
- package/create.js +6 -3
- package/dist/cjs/create.js +6 -3
- package/dist/cjs/event/animationFrame.js +4 -3
- package/dist/cjs/event/on.js +19 -11
- package/dist/cjs/mixins/html.js +1 -1
- package/dist/cjs/set.js +1 -1
- package/dist/cjs/update.js +29 -10
- package/dist/esm/create.js +6 -3
- package/dist/esm/event/animationFrame.js +4 -3
- package/dist/esm/event/on.js +19 -11
- package/dist/esm/mixins/html.js +1 -1
- package/dist/esm/set.js +1 -1
- package/dist/esm/update.js +29 -10
- package/dist/iife/index.js +220 -75
- package/event/animationFrame.js +4 -3
- package/event/on.js +19 -10
- package/mixins/html.js +1 -1
- package/package.json +14 -17
- package/set.js +1 -1
- package/update.js +38 -12
package/README.md
CHANGED
|
@@ -16,4 +16,22 @@ const Poster = {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
DOM.create(Poster, document.body)
|
|
19
|
-
```
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### html mixin
|
|
22
|
+
|
|
23
|
+
The `html` mixin sets raw HTML content on an element. It supports both direct assignment and props:
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
// Direct assignment (el.html)
|
|
27
|
+
const MyComponent = {
|
|
28
|
+
html: '<strong>Hello</strong>'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Via props (el.props.html) — works as an alias
|
|
32
|
+
const MyComponent = {
|
|
33
|
+
props: { html: '<strong>Hello</strong>' }
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`el.html` takes priority when both are set. `props.html` is used as a fallback when `el.html` is not defined.
|
package/create.js
CHANGED
|
@@ -150,7 +150,9 @@ const resetOptions = (element, parent, options) => {
|
|
|
150
150
|
|
|
151
151
|
const addElementIntoParentChildren = (element, parent) => {
|
|
152
152
|
if (parent.__ref && parent.__ref.__children) {
|
|
153
|
-
parent.__ref.__children.
|
|
153
|
+
if (!parent.__ref.__children.includes(element.key)) {
|
|
154
|
+
parent.__ref.__children.push(element.key)
|
|
155
|
+
}
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
158
|
|
|
@@ -175,12 +177,13 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
175
177
|
}
|
|
176
178
|
|
|
177
179
|
// CREATE a real NODE
|
|
178
|
-
if (ENV === 'test' || ENV === 'development') {
|
|
180
|
+
if (ENV === 'test' || ENV === 'development' || element.context?.strictMode) {
|
|
179
181
|
createNestedChild()
|
|
180
182
|
} else {
|
|
181
183
|
try {
|
|
182
184
|
createNestedChild()
|
|
183
185
|
} catch (e) {
|
|
186
|
+
element.error = e
|
|
184
187
|
const path = ref.path
|
|
185
188
|
if (path.includes('ComponentsGrid')) {
|
|
186
189
|
path.splice(0, path.indexOf('ComponentsGrid') + 2)
|
|
@@ -194,7 +197,7 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
194
197
|
isDemoComponent ? isDemoComponent + ' ' : '' + path.join('.')
|
|
195
198
|
)
|
|
196
199
|
element.verbose()
|
|
197
|
-
|
|
200
|
+
console.error('[DomQL] Render error:', e)
|
|
198
201
|
if (element.on?.error) {
|
|
199
202
|
element.on.error(e, element, element.state, element.context, options)
|
|
200
203
|
}
|
package/dist/cjs/create.js
CHANGED
|
@@ -111,7 +111,9 @@ const resetOptions = (element, parent, options) => {
|
|
|
111
111
|
};
|
|
112
112
|
const addElementIntoParentChildren = (element, parent) => {
|
|
113
113
|
if (parent.__ref && parent.__ref.__children) {
|
|
114
|
-
parent.__ref.__children.
|
|
114
|
+
if (!parent.__ref.__children.includes(element.key)) {
|
|
115
|
+
parent.__ref.__children.push(element.key);
|
|
116
|
+
}
|
|
115
117
|
}
|
|
116
118
|
};
|
|
117
119
|
let _uniqIdCounter = 1;
|
|
@@ -130,12 +132,13 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
130
132
|
(0, import_node.createNode)(element, options);
|
|
131
133
|
ref.__uniqId = _uniqIdCounter++;
|
|
132
134
|
};
|
|
133
|
-
if (ENV === "test" || ENV === "development") {
|
|
135
|
+
if (ENV === "test" || ENV === "development" || element.context?.strictMode) {
|
|
134
136
|
createNestedChild();
|
|
135
137
|
} else {
|
|
136
138
|
try {
|
|
137
139
|
createNestedChild();
|
|
138
140
|
} catch (e) {
|
|
141
|
+
element.error = e;
|
|
139
142
|
const path = ref.path;
|
|
140
143
|
if (path.includes("ComponentsGrid")) {
|
|
141
144
|
path.splice(0, path.indexOf("ComponentsGrid") + 2);
|
|
@@ -149,7 +152,7 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
149
152
|
isDemoComponent ? isDemoComponent + " " : "" + path.join(".")
|
|
150
153
|
);
|
|
151
154
|
element.verbose();
|
|
152
|
-
|
|
155
|
+
console.error("[DomQL] Render error:", e);
|
|
153
156
|
if (element.on?.error) {
|
|
154
157
|
element.on.error(e, element, element.state, element.context, options);
|
|
155
158
|
}
|
|
@@ -64,7 +64,8 @@ const processFrameListeners = (frameListeners) => {
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
const startFrameLoop = (frameListeners) => {
|
|
67
|
-
|
|
67
|
+
const raf = typeof window !== "undefined" && window.requestAnimationFrame;
|
|
68
|
+
if (_frameRunning || !raf) return;
|
|
68
69
|
_frameRunning = true;
|
|
69
70
|
function requestFrame() {
|
|
70
71
|
if (frameListeners.size === 0) {
|
|
@@ -72,9 +73,9 @@ const startFrameLoop = (frameListeners) => {
|
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
processFrameListeners(frameListeners);
|
|
75
|
-
|
|
76
|
+
raf(requestFrame);
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
+
raf(requestFrame);
|
|
78
79
|
};
|
|
79
80
|
const applyAnimationFrame = (element) => {
|
|
80
81
|
if (!element) {
|
package/dist/cjs/event/on.js
CHANGED
|
@@ -45,17 +45,25 @@ const registerNodeEvent = (param, element, node, options) => {
|
|
|
45
45
|
}
|
|
46
46
|
const handler = (event) => {
|
|
47
47
|
const { state, context } = element;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
result.
|
|
58
|
-
|
|
48
|
+
try {
|
|
49
|
+
const result = appliedFunction.call(
|
|
50
|
+
element,
|
|
51
|
+
event,
|
|
52
|
+
element,
|
|
53
|
+
state,
|
|
54
|
+
context,
|
|
55
|
+
options
|
|
56
|
+
);
|
|
57
|
+
if (result && typeof result.then === "function") {
|
|
58
|
+
result.catch((err) => {
|
|
59
|
+
element.error = err;
|
|
60
|
+
console.error("[DomQL] Async DOM event error:", err);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
} catch (err) {
|
|
64
|
+
element.error = err;
|
|
65
|
+
console.error("[DomQL] DOM event error:", err);
|
|
66
|
+
if (context?.strictMode) throw err;
|
|
59
67
|
}
|
|
60
68
|
};
|
|
61
69
|
ref.__eventListeners[param] = handler;
|
package/dist/cjs/mixins/html.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(html_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(html_exports);
|
|
25
25
|
var import_utils = require("@domql/utils");
|
|
26
26
|
function html(param, element, node) {
|
|
27
|
-
const prop = (0, import_utils.exec)(element?.props?.html
|
|
27
|
+
const prop = (0, import_utils.exec)(param ?? element?.props?.html, element);
|
|
28
28
|
const { __ref } = element;
|
|
29
29
|
if (prop !== __ref.__html) {
|
|
30
30
|
if (node.nodeName === "SVG") node.textContent = prop;
|
package/dist/cjs/set.js
CHANGED
|
@@ -130,7 +130,7 @@ const set = function(params, options = {}, el) {
|
|
|
130
130
|
}
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
-
if (!params) return element;
|
|
133
|
+
if (!params || typeof params !== "object") return element;
|
|
134
134
|
let { childExtends, props, tag } = params;
|
|
135
135
|
if (!props) props = params.props = {};
|
|
136
136
|
if (tag === "fragment") {
|
package/dist/cjs/update.js
CHANGED
|
@@ -215,6 +215,34 @@ const update = function(params = {}, opts) {
|
|
|
215
215
|
(0, import_event.triggerEventOn)("update", element, options);
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
|
+
const findSiblingAttachOptions = (element, parent) => {
|
|
219
|
+
const { __children } = parent.__ref || {};
|
|
220
|
+
if (!__children) return false;
|
|
221
|
+
const currentIndex = __children.indexOf(element.key);
|
|
222
|
+
let previousNode;
|
|
223
|
+
for (let i = currentIndex - 1; i >= 0; i--) {
|
|
224
|
+
const sibling = parent[__children[i]];
|
|
225
|
+
if (sibling?.node?.parentNode) {
|
|
226
|
+
previousNode = sibling.node;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (previousNode) {
|
|
231
|
+
return { position: "after", node: previousNode };
|
|
232
|
+
}
|
|
233
|
+
let nextNode;
|
|
234
|
+
for (let i = currentIndex + 1; i < __children.length; i++) {
|
|
235
|
+
const sibling = parent[__children[i]];
|
|
236
|
+
if (sibling?.node?.parentNode) {
|
|
237
|
+
nextNode = sibling.node;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (nextNode) {
|
|
242
|
+
return { position: "before", node: nextNode };
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
};
|
|
218
246
|
const checkIfOnUpdate = (element, parent, options) => {
|
|
219
247
|
if (!(0, import_utils.isFunction)(element.if) && !(0, import_utils.isFunction)(element.props?.if) || !parent) {
|
|
220
248
|
return;
|
|
@@ -251,16 +279,7 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
251
279
|
} else if (element[contentKey]?.parseDeep) {
|
|
252
280
|
element[contentKey] = element[contentKey].parseDeep();
|
|
253
281
|
}
|
|
254
|
-
const
|
|
255
|
-
const previousNode = previousElement?.node;
|
|
256
|
-
const hasPrevious = previousNode?.parentNode;
|
|
257
|
-
const nextElement = element.nextElement();
|
|
258
|
-
const nextNode = nextElement?.node;
|
|
259
|
-
const hasNext = nextNode?.parentNode;
|
|
260
|
-
const attachOptions = (hasPrevious || hasNext) && {
|
|
261
|
-
position: hasPrevious ? "after" : hasNext ? "before" : null,
|
|
262
|
-
node: hasPrevious && previousNode || hasNext && nextNode
|
|
263
|
-
};
|
|
282
|
+
const attachOptions = findSiblingAttachOptions(element, parent);
|
|
264
283
|
delete element.__ref;
|
|
265
284
|
delete element.parent;
|
|
266
285
|
const createdElement = (0, import_create.create)(
|
package/dist/esm/create.js
CHANGED
|
@@ -102,7 +102,9 @@ const resetOptions = (element, parent, options) => {
|
|
|
102
102
|
};
|
|
103
103
|
const addElementIntoParentChildren = (element, parent) => {
|
|
104
104
|
if (parent.__ref && parent.__ref.__children) {
|
|
105
|
-
parent.__ref.__children.
|
|
105
|
+
if (!parent.__ref.__children.includes(element.key)) {
|
|
106
|
+
parent.__ref.__children.push(element.key);
|
|
107
|
+
}
|
|
106
108
|
}
|
|
107
109
|
};
|
|
108
110
|
let _uniqIdCounter = 1;
|
|
@@ -121,12 +123,13 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
121
123
|
createNode(element, options);
|
|
122
124
|
ref.__uniqId = _uniqIdCounter++;
|
|
123
125
|
};
|
|
124
|
-
if (ENV === "test" || ENV === "development") {
|
|
126
|
+
if (ENV === "test" || ENV === "development" || element.context?.strictMode) {
|
|
125
127
|
createNestedChild();
|
|
126
128
|
} else {
|
|
127
129
|
try {
|
|
128
130
|
createNestedChild();
|
|
129
131
|
} catch (e) {
|
|
132
|
+
element.error = e;
|
|
130
133
|
const path = ref.path;
|
|
131
134
|
if (path.includes("ComponentsGrid")) {
|
|
132
135
|
path.splice(0, path.indexOf("ComponentsGrid") + 2);
|
|
@@ -140,7 +143,7 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
140
143
|
isDemoComponent ? isDemoComponent + " " : "" + path.join(".")
|
|
141
144
|
);
|
|
142
145
|
element.verbose();
|
|
143
|
-
|
|
146
|
+
console.error("[DomQL] Render error:", e);
|
|
144
147
|
if (element.on?.error) {
|
|
145
148
|
element.on.error(e, element, element.state, element.context, options);
|
|
146
149
|
}
|
|
@@ -39,7 +39,8 @@ const processFrameListeners = (frameListeners) => {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
const startFrameLoop = (frameListeners) => {
|
|
42
|
-
|
|
42
|
+
const raf = typeof window !== "undefined" && window.requestAnimationFrame;
|
|
43
|
+
if (_frameRunning || !raf) return;
|
|
43
44
|
_frameRunning = true;
|
|
44
45
|
function requestFrame() {
|
|
45
46
|
if (frameListeners.size === 0) {
|
|
@@ -47,9 +48,9 @@ const startFrameLoop = (frameListeners) => {
|
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
processFrameListeners(frameListeners);
|
|
50
|
-
|
|
51
|
+
raf(requestFrame);
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
raf(requestFrame);
|
|
53
54
|
};
|
|
54
55
|
const applyAnimationFrame = (element) => {
|
|
55
56
|
if (!element) {
|
package/dist/esm/event/on.js
CHANGED
|
@@ -18,17 +18,25 @@ const registerNodeEvent = (param, element, node, options) => {
|
|
|
18
18
|
}
|
|
19
19
|
const handler = (event) => {
|
|
20
20
|
const { state, context } = element;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
result.
|
|
31
|
-
|
|
21
|
+
try {
|
|
22
|
+
const result = appliedFunction.call(
|
|
23
|
+
element,
|
|
24
|
+
event,
|
|
25
|
+
element,
|
|
26
|
+
state,
|
|
27
|
+
context,
|
|
28
|
+
options
|
|
29
|
+
);
|
|
30
|
+
if (result && typeof result.then === "function") {
|
|
31
|
+
result.catch((err) => {
|
|
32
|
+
element.error = err;
|
|
33
|
+
console.error("[DomQL] Async DOM event error:", err);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
} catch (err) {
|
|
37
|
+
element.error = err;
|
|
38
|
+
console.error("[DomQL] DOM event error:", err);
|
|
39
|
+
if (context?.strictMode) throw err;
|
|
32
40
|
}
|
|
33
41
|
};
|
|
34
42
|
ref.__eventListeners[param] = handler;
|
package/dist/esm/mixins/html.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { exec } from "@domql/utils";
|
|
2
2
|
function html(param, element, node) {
|
|
3
|
-
const prop = exec(element?.props?.html
|
|
3
|
+
const prop = exec(param ?? element?.props?.html, element);
|
|
4
4
|
const { __ref } = element;
|
|
5
5
|
if (prop !== __ref.__html) {
|
|
6
6
|
if (node.nodeName === "SVG") node.textContent = prop;
|
package/dist/esm/set.js
CHANGED
|
@@ -100,7 +100,7 @@ const set = function(params, options = {}, el) {
|
|
|
100
100
|
}
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
if (!params) return element;
|
|
103
|
+
if (!params || typeof params !== "object") return element;
|
|
104
104
|
let { childExtends, props, tag } = params;
|
|
105
105
|
if (!props) props = params.props = {};
|
|
106
106
|
if (tag === "fragment") {
|
package/dist/esm/update.js
CHANGED
|
@@ -202,6 +202,34 @@ const update = function(params = {}, opts) {
|
|
|
202
202
|
triggerEventOn("update", element, options);
|
|
203
203
|
}
|
|
204
204
|
};
|
|
205
|
+
const findSiblingAttachOptions = (element, parent) => {
|
|
206
|
+
const { __children } = parent.__ref || {};
|
|
207
|
+
if (!__children) return false;
|
|
208
|
+
const currentIndex = __children.indexOf(element.key);
|
|
209
|
+
let previousNode;
|
|
210
|
+
for (let i = currentIndex - 1; i >= 0; i--) {
|
|
211
|
+
const sibling = parent[__children[i]];
|
|
212
|
+
if (sibling?.node?.parentNode) {
|
|
213
|
+
previousNode = sibling.node;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (previousNode) {
|
|
218
|
+
return { position: "after", node: previousNode };
|
|
219
|
+
}
|
|
220
|
+
let nextNode;
|
|
221
|
+
for (let i = currentIndex + 1; i < __children.length; i++) {
|
|
222
|
+
const sibling = parent[__children[i]];
|
|
223
|
+
if (sibling?.node?.parentNode) {
|
|
224
|
+
nextNode = sibling.node;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (nextNode) {
|
|
229
|
+
return { position: "before", node: nextNode };
|
|
230
|
+
}
|
|
231
|
+
return false;
|
|
232
|
+
};
|
|
205
233
|
const checkIfOnUpdate = (element, parent, options) => {
|
|
206
234
|
if (!isFunction(element.if) && !isFunction(element.props?.if) || !parent) {
|
|
207
235
|
return;
|
|
@@ -238,16 +266,7 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
238
266
|
} else if (element[contentKey]?.parseDeep) {
|
|
239
267
|
element[contentKey] = element[contentKey].parseDeep();
|
|
240
268
|
}
|
|
241
|
-
const
|
|
242
|
-
const previousNode = previousElement?.node;
|
|
243
|
-
const hasPrevious = previousNode?.parentNode;
|
|
244
|
-
const nextElement = element.nextElement();
|
|
245
|
-
const nextNode = nextElement?.node;
|
|
246
|
-
const hasNext = nextNode?.parentNode;
|
|
247
|
-
const attachOptions = (hasPrevious || hasNext) && {
|
|
248
|
-
position: hasPrevious ? "after" : hasNext ? "before" : null,
|
|
249
|
-
node: hasPrevious && previousNode || hasNext && nextNode
|
|
250
|
-
};
|
|
269
|
+
const attachOptions = findSiblingAttachOptions(element, parent);
|
|
251
270
|
delete element.__ref;
|
|
252
271
|
delete element.parent;
|
|
253
272
|
const createdElement = create(
|
package/dist/iife/index.js
CHANGED
|
@@ -57,7 +57,7 @@ var DomqlElement = (() => {
|
|
|
57
57
|
return (typeof HTMLElement === "object" ? obj instanceof window2.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string") || false;
|
|
58
58
|
};
|
|
59
59
|
var isDOMNode = (obj) => {
|
|
60
|
-
return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
|
|
60
|
+
return typeof window2 !== "undefined" && (window2.Node && obj instanceof window2.Node || window2.Window && obj instanceof window2.Window || obj === window2 || obj === document);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
// ../utils/dist/esm/types.js
|
|
@@ -801,6 +801,7 @@ var DomqlElement = (() => {
|
|
|
801
801
|
|
|
802
802
|
// ../utils/dist/esm/extends.js
|
|
803
803
|
var ENV2 = process.env.NODE_ENV;
|
|
804
|
+
var isSourcemapEnabled = (options) => options.sourcemap !== false && ENV2 !== "production";
|
|
804
805
|
var createExtendsFromKeys = (key) => {
|
|
805
806
|
if (key.includes("+")) {
|
|
806
807
|
return key.split("+").filter(matchesComponentNaming);
|
|
@@ -874,17 +875,17 @@ var DomqlElement = (() => {
|
|
|
874
875
|
}
|
|
875
876
|
return setHashedExtend(extend, stack);
|
|
876
877
|
};
|
|
877
|
-
var extractArrayExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
|
|
878
|
+
var extractArrayExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set(), nameStack, componentNameMap) => {
|
|
878
879
|
for (const each of extend) {
|
|
879
880
|
if (isArray(each)) {
|
|
880
|
-
extractArrayExtend(each, stack, context, processed);
|
|
881
|
+
extractArrayExtend(each, stack, context, processed, nameStack, componentNameMap);
|
|
881
882
|
} else {
|
|
882
|
-
flattenExtend(each, stack, context, processed);
|
|
883
|
+
flattenExtend(each, stack, context, processed, nameStack, void 0, componentNameMap);
|
|
883
884
|
}
|
|
884
885
|
}
|
|
885
886
|
return stack;
|
|
886
887
|
};
|
|
887
|
-
var deepExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
|
|
888
|
+
var deepExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set(), nameStack, currentName, componentNameMap) => {
|
|
888
889
|
const extendOflattenExtend = extend.extends || extend.extend;
|
|
889
890
|
const cleanExtend = { ...extend };
|
|
890
891
|
delete cleanExtend.extends;
|
|
@@ -896,26 +897,32 @@ var DomqlElement = (() => {
|
|
|
896
897
|
}
|
|
897
898
|
if (hasKeys) {
|
|
898
899
|
stack.push(cleanExtend);
|
|
900
|
+
if (nameStack) nameStack.push(currentName);
|
|
899
901
|
}
|
|
900
902
|
if (extendOflattenExtend) {
|
|
901
|
-
flattenExtend(extendOflattenExtend, stack, context, processed);
|
|
903
|
+
flattenExtend(extendOflattenExtend, stack, context, processed, nameStack, currentName, componentNameMap);
|
|
902
904
|
}
|
|
903
905
|
return stack;
|
|
904
906
|
};
|
|
905
|
-
var flattenExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
|
|
907
|
+
var flattenExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set(), nameStack, parentName, componentNameMap) => {
|
|
906
908
|
if (!extend) return stack;
|
|
907
909
|
if (processed.has(extend)) return stack;
|
|
908
910
|
if (isArray(extend)) {
|
|
909
|
-
return extractArrayExtend(extend, stack, context, processed);
|
|
911
|
+
return extractArrayExtend(extend, stack, context, processed, nameStack, componentNameMap);
|
|
910
912
|
}
|
|
913
|
+
let currentName = parentName;
|
|
911
914
|
if (isString(extend)) {
|
|
915
|
+
currentName = extend;
|
|
912
916
|
extend = mapStringsWithContextComponents(extend, context);
|
|
917
|
+
} else if (componentNameMap && isObject(extend) && componentNameMap.has(extend)) {
|
|
918
|
+
currentName = componentNameMap.get(extend);
|
|
913
919
|
}
|
|
914
920
|
processed.add(extend);
|
|
915
921
|
if (extend?.extends || extend?.extend) {
|
|
916
|
-
deepExtend(extend, stack, context, processed);
|
|
922
|
+
deepExtend(extend, stack, context, processed, nameStack, currentName, componentNameMap);
|
|
917
923
|
} else if (extend) {
|
|
918
924
|
stack.push(extend);
|
|
925
|
+
if (nameStack) nameStack.push(currentName);
|
|
919
926
|
}
|
|
920
927
|
return stack;
|
|
921
928
|
};
|
|
@@ -928,7 +935,7 @@ var DomqlElement = (() => {
|
|
|
928
935
|
"childExtend",
|
|
929
936
|
"childExtendRecursive"
|
|
930
937
|
]);
|
|
931
|
-
var deepMergeExtends = (element, extend) => {
|
|
938
|
+
var deepMergeExtends = (element, extend, sourcemap, sourceName, preBuiltSourcemap) => {
|
|
932
939
|
extend = deepClone(extend);
|
|
933
940
|
for (const e in extend) {
|
|
934
941
|
if (MERGE_EXTENDS_SKIP.has(e)) continue;
|
|
@@ -938,11 +945,23 @@ var DomqlElement = (() => {
|
|
|
938
945
|
if (Object.prototype.hasOwnProperty.call(extend, e) && e !== "__proto__" && e !== "constructor" && e !== "prototype") {
|
|
939
946
|
if (elementProp === void 0) {
|
|
940
947
|
element[e] = extendProp;
|
|
948
|
+
if (sourcemap && sourceName) {
|
|
949
|
+
if (isObject(extendProp) && !isArray(extendProp)) {
|
|
950
|
+
sourcemap[e] = sourcemap[e] || {};
|
|
951
|
+
trackSourcemapDeep(sourcemap[e], extendProp, sourceName);
|
|
952
|
+
} else {
|
|
953
|
+
sourcemap[e] = sourceName;
|
|
954
|
+
}
|
|
955
|
+
} else if (sourcemap && preBuiltSourcemap?.[e]) {
|
|
956
|
+
sourcemap[e] = preBuiltSourcemap[e];
|
|
957
|
+
}
|
|
941
958
|
} else if (isObject(elementProp) && isObject(extendProp)) {
|
|
959
|
+
const nestedSourcemap = sourcemap ? sourcemap[e] = sourcemap[e] || {} : void 0;
|
|
960
|
+
const nestedPreBuilt = preBuiltSourcemap?.[e];
|
|
942
961
|
if (matchesComponentNaming(e)) {
|
|
943
|
-
element[e] = deepMergeExtends(elementProp, extendProp);
|
|
962
|
+
element[e] = deepMergeExtends(elementProp, extendProp, nestedSourcemap, sourceName, nestedPreBuilt);
|
|
944
963
|
} else {
|
|
945
|
-
deepMergeExtends(elementProp, extendProp);
|
|
964
|
+
deepMergeExtends(elementProp, extendProp, nestedSourcemap, sourceName, nestedPreBuilt);
|
|
946
965
|
}
|
|
947
966
|
}
|
|
948
967
|
if (e === "extends" || e === "childExtends" || e === "childExtendsRecursive") {
|
|
@@ -957,10 +976,24 @@ var DomqlElement = (() => {
|
|
|
957
976
|
}
|
|
958
977
|
return element;
|
|
959
978
|
};
|
|
960
|
-
var
|
|
961
|
-
|
|
979
|
+
var trackSourcemapDeep = (sourcemap, obj, sourceName) => {
|
|
980
|
+
for (const key in obj) {
|
|
981
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
982
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
983
|
+
const val = obj[key];
|
|
984
|
+
if (isObject(val) && !isArray(val)) {
|
|
985
|
+
sourcemap[key] = sourcemap[key] || {};
|
|
986
|
+
trackSourcemapDeep(sourcemap[key], val, sourceName);
|
|
987
|
+
} else {
|
|
988
|
+
sourcemap[key] = sourceName;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
var cloneAndMergeArrayExtend = (stack, sourcemap, extendNames) => {
|
|
993
|
+
return stack.reduce((acc, current, i) => {
|
|
962
994
|
const cloned = deepClone(current);
|
|
963
|
-
|
|
995
|
+
const sourceName = extendNames ? extendNames[i] : void 0;
|
|
996
|
+
return deepMergeExtends(acc, cloned, sourcemap, sourceName);
|
|
964
997
|
}, {});
|
|
965
998
|
};
|
|
966
999
|
var mapStringsWithContextComponents = (extend, context, options = {}, variant) => {
|
|
@@ -980,11 +1013,12 @@ var DomqlElement = (() => {
|
|
|
980
1013
|
}
|
|
981
1014
|
return extend;
|
|
982
1015
|
};
|
|
983
|
-
var getExtendsStack = (extend, context) => {
|
|
1016
|
+
var getExtendsStack = (extend, context, nameStack, componentNameMap) => {
|
|
984
1017
|
if (!extend) return [];
|
|
985
1018
|
if (extend.__hash) return getHashedExtend(extend) || [];
|
|
986
1019
|
const processed = /* @__PURE__ */ new Set();
|
|
987
|
-
const stack = flattenExtend(extend, [], context, processed);
|
|
1020
|
+
const stack = flattenExtend(extend, [], context, processed, nameStack, void 0, componentNameMap);
|
|
1021
|
+
if (nameStack) return stack;
|
|
988
1022
|
return getExtendsStackRegistry(extend, stack);
|
|
989
1023
|
};
|
|
990
1024
|
var createElementExtends = (element, parent, options = {}) => {
|
|
@@ -1062,6 +1096,8 @@ var DomqlElement = (() => {
|
|
|
1062
1096
|
const { props, __ref: ref } = element;
|
|
1063
1097
|
const context = element.context || parent.context;
|
|
1064
1098
|
const variant = element.variant || props?.variant;
|
|
1099
|
+
const sourcemap = isSourcemapEnabled(options);
|
|
1100
|
+
const originalExtendNames = sourcemap ? [...ref.__extends] : null;
|
|
1065
1101
|
const __extends = removeDuplicatesInArray(
|
|
1066
1102
|
ref.__extends.map((val, i) => {
|
|
1067
1103
|
return mapStringsWithContextComponents(
|
|
@@ -1072,15 +1108,40 @@ var DomqlElement = (() => {
|
|
|
1072
1108
|
);
|
|
1073
1109
|
})
|
|
1074
1110
|
);
|
|
1075
|
-
|
|
1076
|
-
|
|
1111
|
+
if (sourcemap) {
|
|
1112
|
+
const componentNameMap = /* @__PURE__ */ new WeakMap();
|
|
1113
|
+
for (let i = 0; i < __extends.length; i++) {
|
|
1114
|
+
const resolved = __extends[i];
|
|
1115
|
+
const originalName = originalExtendNames[i];
|
|
1116
|
+
if (resolved && isObject(resolved) && isString(originalName)) {
|
|
1117
|
+
componentNameMap.set(resolved, originalName);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
const nameStack = [];
|
|
1121
|
+
const stack = getExtendsStack(__extends, context, nameStack, componentNameMap);
|
|
1122
|
+
ref.__extendsStack = stack;
|
|
1123
|
+
ref.__extendsNames = nameStack;
|
|
1124
|
+
} else {
|
|
1125
|
+
const stack = getExtendsStack(__extends, context);
|
|
1126
|
+
ref.__extendsStack = stack;
|
|
1127
|
+
}
|
|
1077
1128
|
return ref.__extendsStack;
|
|
1078
1129
|
};
|
|
1079
1130
|
var finalizeExtends = (element, parent, options = {}) => {
|
|
1080
1131
|
const { __ref: ref } = element;
|
|
1081
1132
|
const { __extendsStack } = ref;
|
|
1082
|
-
|
|
1083
|
-
|
|
1133
|
+
if (isSourcemapEnabled(options)) {
|
|
1134
|
+
const sourcemapAcc = {};
|
|
1135
|
+
const extendNames = ref.__extendsNames || [];
|
|
1136
|
+
const flattenExtends = cloneAndMergeArrayExtend(__extendsStack, sourcemapAcc, extendNames);
|
|
1137
|
+
const appliedSourcemap = {};
|
|
1138
|
+
deepMergeExtends(element, flattenExtends, appliedSourcemap, void 0, sourcemapAcc);
|
|
1139
|
+
ref.__sourcemap = appliedSourcemap;
|
|
1140
|
+
} else {
|
|
1141
|
+
const flattenExtends = cloneAndMergeArrayExtend(__extendsStack);
|
|
1142
|
+
deepMergeExtends(element, flattenExtends);
|
|
1143
|
+
}
|
|
1144
|
+
return element;
|
|
1084
1145
|
};
|
|
1085
1146
|
var applyExtends = (element, parent, options = {}) => {
|
|
1086
1147
|
createElementExtends(element, parent, options);
|
|
@@ -1119,6 +1180,30 @@ var DomqlElement = (() => {
|
|
|
1119
1180
|
// ../utils/dist/esm/props.js
|
|
1120
1181
|
var RE_UPPER = /^[A-Z]/;
|
|
1121
1182
|
var RE_DIGITS = /^\d+$/;
|
|
1183
|
+
var ELEMENT_INDICATOR_KEYS = /* @__PURE__ */ new Set([
|
|
1184
|
+
"extend",
|
|
1185
|
+
"props",
|
|
1186
|
+
"text",
|
|
1187
|
+
"tag",
|
|
1188
|
+
"on",
|
|
1189
|
+
"if",
|
|
1190
|
+
"childExtend",
|
|
1191
|
+
"children",
|
|
1192
|
+
"childrenAs",
|
|
1193
|
+
"state",
|
|
1194
|
+
"html",
|
|
1195
|
+
"attr",
|
|
1196
|
+
"define",
|
|
1197
|
+
"content"
|
|
1198
|
+
]);
|
|
1199
|
+
var looksLikeElement = (value) => {
|
|
1200
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1201
|
+
for (const k in value) {
|
|
1202
|
+
if (ELEMENT_INDICATOR_KEYS.has(k)) return true;
|
|
1203
|
+
if (RE_UPPER.test(k)) return true;
|
|
1204
|
+
}
|
|
1205
|
+
return false;
|
|
1206
|
+
};
|
|
1122
1207
|
var createProps = (element, parent, key) => {
|
|
1123
1208
|
const { props, __ref: ref } = element;
|
|
1124
1209
|
ref.__propsStack = [];
|
|
@@ -1143,7 +1228,7 @@ var DomqlElement = (() => {
|
|
|
1143
1228
|
}
|
|
1144
1229
|
const hasDefine = isObject(this.define?.[key]);
|
|
1145
1230
|
const hasGlobalDefine = isObject(this.context?.define?.[key]);
|
|
1146
|
-
const isElement = RE_UPPER.test(key) || RE_DIGITS.test(key);
|
|
1231
|
+
const isElement = RE_UPPER.test(key) || RE_DIGITS.test(key) || looksLikeElement(value);
|
|
1147
1232
|
const isBuiltin = DOMQ_PROPERTIES.has(key);
|
|
1148
1233
|
if (!isElement && !isBuiltin && !hasDefine && !hasGlobalDefine) {
|
|
1149
1234
|
obj.props[key] = value;
|
|
@@ -1564,18 +1649,26 @@ var DomqlElement = (() => {
|
|
|
1564
1649
|
};
|
|
1565
1650
|
var applyEvent = (param, element, state2, context, options) => {
|
|
1566
1651
|
if (!isFunction(param)) return;
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
result.
|
|
1576
|
-
|
|
1652
|
+
try {
|
|
1653
|
+
const result = param.call(
|
|
1654
|
+
element,
|
|
1655
|
+
element,
|
|
1656
|
+
state2 || element.state,
|
|
1657
|
+
context || element.context,
|
|
1658
|
+
options
|
|
1659
|
+
);
|
|
1660
|
+
if (result && typeof result.then === "function") {
|
|
1661
|
+
result.catch((err) => {
|
|
1662
|
+
element.error = err;
|
|
1663
|
+
console.error("[DomQL] Async event error:", err);
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
return result;
|
|
1667
|
+
} catch (err) {
|
|
1668
|
+
element.error = err;
|
|
1669
|
+
console.error("[DomQL] Event handler error:", err);
|
|
1670
|
+
if (element.context?.strictMode) throw err;
|
|
1577
1671
|
}
|
|
1578
|
-
return result;
|
|
1579
1672
|
};
|
|
1580
1673
|
var triggerEventOn = (param, element, options) => {
|
|
1581
1674
|
if (!element) {
|
|
@@ -1589,19 +1682,27 @@ var DomqlElement = (() => {
|
|
|
1589
1682
|
};
|
|
1590
1683
|
var applyEventUpdate = (param, updatedObj, element, state2, context, options) => {
|
|
1591
1684
|
if (!isFunction(param)) return;
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
result.
|
|
1602
|
-
|
|
1685
|
+
try {
|
|
1686
|
+
const result = param.call(
|
|
1687
|
+
element,
|
|
1688
|
+
updatedObj,
|
|
1689
|
+
element,
|
|
1690
|
+
state2 || element.state,
|
|
1691
|
+
context || element.context,
|
|
1692
|
+
options
|
|
1693
|
+
);
|
|
1694
|
+
if (result && typeof result.then === "function") {
|
|
1695
|
+
result.catch((err) => {
|
|
1696
|
+
element.error = err;
|
|
1697
|
+
console.error("[DomQL] Async event update error:", err);
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
return result;
|
|
1701
|
+
} catch (err) {
|
|
1702
|
+
element.error = err;
|
|
1703
|
+
console.error("[DomQL] Event update error:", err);
|
|
1704
|
+
if (element.context?.strictMode) throw err;
|
|
1603
1705
|
}
|
|
1604
|
-
return result;
|
|
1605
1706
|
};
|
|
1606
1707
|
var triggerEventOnUpdate = (param, updatedObj, element, options) => {
|
|
1607
1708
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
@@ -1908,7 +2009,20 @@ var DomqlElement = (() => {
|
|
|
1908
2009
|
}
|
|
1909
2010
|
function call(fnKey, ...args) {
|
|
1910
2011
|
const context = this.context;
|
|
1911
|
-
|
|
2012
|
+
const fn = context.utils?.[fnKey] || context.functions?.[fnKey] || context.methods?.[fnKey] || context.snippets?.[fnKey];
|
|
2013
|
+
if (!fn) return;
|
|
2014
|
+
try {
|
|
2015
|
+
const result = fn.call(this, ...args);
|
|
2016
|
+
if (result && typeof result.then === "function") {
|
|
2017
|
+
result.catch((err) => {
|
|
2018
|
+
this.error = err;
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
return result;
|
|
2022
|
+
} catch (err) {
|
|
2023
|
+
this.error = err;
|
|
2024
|
+
if (context?.strictMode) throw err;
|
|
2025
|
+
}
|
|
1912
2026
|
}
|
|
1913
2027
|
function isMethod(param, element) {
|
|
1914
2028
|
return Boolean(METHODS.has(param) || element?.context?.methods?.[param]);
|
|
@@ -2029,17 +2143,25 @@ ${element}` : "";
|
|
|
2029
2143
|
}
|
|
2030
2144
|
const handler = (event) => {
|
|
2031
2145
|
const { state: state2, context } = element;
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
result.
|
|
2042
|
-
|
|
2146
|
+
try {
|
|
2147
|
+
const result = appliedFunction.call(
|
|
2148
|
+
element,
|
|
2149
|
+
event,
|
|
2150
|
+
element,
|
|
2151
|
+
state2,
|
|
2152
|
+
context,
|
|
2153
|
+
options
|
|
2154
|
+
);
|
|
2155
|
+
if (result && typeof result.then === "function") {
|
|
2156
|
+
result.catch((err) => {
|
|
2157
|
+
element.error = err;
|
|
2158
|
+
console.error("[DomQL] Async DOM event error:", err);
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
} catch (err) {
|
|
2162
|
+
element.error = err;
|
|
2163
|
+
console.error("[DomQL] DOM event error:", err);
|
|
2164
|
+
if (context?.strictMode) throw err;
|
|
2043
2165
|
}
|
|
2044
2166
|
};
|
|
2045
2167
|
ref.__eventListeners[param] = handler;
|
|
@@ -2114,7 +2236,8 @@ ${element}` : "";
|
|
|
2114
2236
|
}
|
|
2115
2237
|
};
|
|
2116
2238
|
var startFrameLoop = (frameListeners) => {
|
|
2117
|
-
|
|
2239
|
+
const raf = typeof window !== "undefined" && window.requestAnimationFrame;
|
|
2240
|
+
if (_frameRunning || !raf) return;
|
|
2118
2241
|
_frameRunning = true;
|
|
2119
2242
|
function requestFrame() {
|
|
2120
2243
|
if (frameListeners.size === 0) {
|
|
@@ -2122,9 +2245,9 @@ ${element}` : "";
|
|
|
2122
2245
|
return;
|
|
2123
2246
|
}
|
|
2124
2247
|
processFrameListeners(frameListeners);
|
|
2125
|
-
|
|
2248
|
+
raf(requestFrame);
|
|
2126
2249
|
}
|
|
2127
|
-
|
|
2250
|
+
raf(requestFrame);
|
|
2128
2251
|
};
|
|
2129
2252
|
var applyAnimationFrame = (element) => {
|
|
2130
2253
|
if (!element) {
|
|
@@ -2507,7 +2630,7 @@ ${element}` : "";
|
|
|
2507
2630
|
|
|
2508
2631
|
// mixins/html.js
|
|
2509
2632
|
function html(param, element, node) {
|
|
2510
|
-
const prop = exec(element?.props?.html
|
|
2633
|
+
const prop = exec(param ?? element?.props?.html, element);
|
|
2511
2634
|
const { __ref } = element;
|
|
2512
2635
|
if (prop !== __ref.__html) {
|
|
2513
2636
|
if (node.nodeName === "SVG") node.textContent = prop;
|
|
@@ -2837,7 +2960,7 @@ ${element}` : "";
|
|
|
2837
2960
|
}
|
|
2838
2961
|
return;
|
|
2839
2962
|
}
|
|
2840
|
-
if (!params) return element;
|
|
2963
|
+
if (!params || typeof params !== "object") return element;
|
|
2841
2964
|
let { childExtends, props, tag } = params;
|
|
2842
2965
|
if (!props) props = params.props = {};
|
|
2843
2966
|
if (tag === "fragment") {
|
|
@@ -3458,6 +3581,34 @@ ${element}` : "";
|
|
|
3458
3581
|
triggerEventOn("update", element, options);
|
|
3459
3582
|
}
|
|
3460
3583
|
};
|
|
3584
|
+
var findSiblingAttachOptions = (element, parent) => {
|
|
3585
|
+
const { __children } = parent.__ref || {};
|
|
3586
|
+
if (!__children) return false;
|
|
3587
|
+
const currentIndex = __children.indexOf(element.key);
|
|
3588
|
+
let previousNode;
|
|
3589
|
+
for (let i = currentIndex - 1; i >= 0; i--) {
|
|
3590
|
+
const sibling = parent[__children[i]];
|
|
3591
|
+
if (sibling?.node?.parentNode) {
|
|
3592
|
+
previousNode = sibling.node;
|
|
3593
|
+
break;
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
if (previousNode) {
|
|
3597
|
+
return { position: "after", node: previousNode };
|
|
3598
|
+
}
|
|
3599
|
+
let nextNode;
|
|
3600
|
+
for (let i = currentIndex + 1; i < __children.length; i++) {
|
|
3601
|
+
const sibling = parent[__children[i]];
|
|
3602
|
+
if (sibling?.node?.parentNode) {
|
|
3603
|
+
nextNode = sibling.node;
|
|
3604
|
+
break;
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
if (nextNode) {
|
|
3608
|
+
return { position: "before", node: nextNode };
|
|
3609
|
+
}
|
|
3610
|
+
return false;
|
|
3611
|
+
};
|
|
3461
3612
|
var checkIfOnUpdate = (element, parent, options) => {
|
|
3462
3613
|
if (!isFunction(element.if) && !isFunction(element.props?.if) || !parent) {
|
|
3463
3614
|
return;
|
|
@@ -3494,16 +3645,7 @@ ${element}` : "";
|
|
|
3494
3645
|
} else if (element[contentKey]?.parseDeep) {
|
|
3495
3646
|
element[contentKey] = element[contentKey].parseDeep();
|
|
3496
3647
|
}
|
|
3497
|
-
const
|
|
3498
|
-
const previousNode = previousElement2?.node;
|
|
3499
|
-
const hasPrevious = previousNode?.parentNode;
|
|
3500
|
-
const nextElement2 = element.nextElement();
|
|
3501
|
-
const nextNode = nextElement2?.node;
|
|
3502
|
-
const hasNext = nextNode?.parentNode;
|
|
3503
|
-
const attachOptions = (hasPrevious || hasNext) && {
|
|
3504
|
-
position: hasPrevious ? "after" : hasNext ? "before" : null,
|
|
3505
|
-
node: hasPrevious && previousNode || hasNext && nextNode
|
|
3506
|
-
};
|
|
3648
|
+
const attachOptions = findSiblingAttachOptions(element, parent);
|
|
3507
3649
|
delete element.__ref;
|
|
3508
3650
|
delete element.parent;
|
|
3509
3651
|
const createdElement = create(
|
|
@@ -4612,7 +4754,9 @@ ${element}` : "";
|
|
|
4612
4754
|
};
|
|
4613
4755
|
var addElementIntoParentChildren = (element, parent) => {
|
|
4614
4756
|
if (parent.__ref && parent.__ref.__children) {
|
|
4615
|
-
parent.__ref.__children.
|
|
4757
|
+
if (!parent.__ref.__children.includes(element.key)) {
|
|
4758
|
+
parent.__ref.__children.push(element.key);
|
|
4759
|
+
}
|
|
4616
4760
|
}
|
|
4617
4761
|
};
|
|
4618
4762
|
var _uniqIdCounter = 1;
|
|
@@ -4631,12 +4775,13 @@ ${element}` : "";
|
|
|
4631
4775
|
createNode(element, options);
|
|
4632
4776
|
ref.__uniqId = _uniqIdCounter++;
|
|
4633
4777
|
};
|
|
4634
|
-
if (ENV6 === "test" || ENV6 === "development") {
|
|
4778
|
+
if (ENV6 === "test" || ENV6 === "development" || element.context?.strictMode) {
|
|
4635
4779
|
createNestedChild();
|
|
4636
4780
|
} else {
|
|
4637
4781
|
try {
|
|
4638
4782
|
createNestedChild();
|
|
4639
4783
|
} catch (e) {
|
|
4784
|
+
element.error = e;
|
|
4640
4785
|
const path = ref.path;
|
|
4641
4786
|
if (path.includes("ComponentsGrid")) {
|
|
4642
4787
|
path.splice(0, path.indexOf("ComponentsGrid") + 2);
|
|
@@ -4650,7 +4795,7 @@ ${element}` : "";
|
|
|
4650
4795
|
isDemoComponent ? isDemoComponent + " " : "" + path.join(".")
|
|
4651
4796
|
);
|
|
4652
4797
|
element.verbose();
|
|
4653
|
-
|
|
4798
|
+
console.error("[DomQL] Render error:", e);
|
|
4654
4799
|
if (element.on?.error) {
|
|
4655
4800
|
element.on.error(e, element, element.state, element.context, options);
|
|
4656
4801
|
}
|
package/event/animationFrame.js
CHANGED
|
@@ -51,7 +51,8 @@ const processFrameListeners = (frameListeners) => {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const startFrameLoop = (frameListeners) => {
|
|
54
|
-
|
|
54
|
+
const raf = typeof window !== 'undefined' && window.requestAnimationFrame
|
|
55
|
+
if (_frameRunning || !raf) return
|
|
55
56
|
_frameRunning = true
|
|
56
57
|
|
|
57
58
|
function requestFrame () {
|
|
@@ -60,10 +61,10 @@ const startFrameLoop = (frameListeners) => {
|
|
|
60
61
|
return
|
|
61
62
|
}
|
|
62
63
|
processFrameListeners(frameListeners)
|
|
63
|
-
|
|
64
|
+
raf(requestFrame)
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
raf(requestFrame)
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
export const applyAnimationFrame = element => {
|
package/event/on.js
CHANGED
|
@@ -27,16 +27,25 @@ const registerNodeEvent = (param, element, node, options) => {
|
|
|
27
27
|
|
|
28
28
|
const handler = event => {
|
|
29
29
|
const { state, context } = element
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
result.
|
|
30
|
+
try {
|
|
31
|
+
const result = appliedFunction.call(
|
|
32
|
+
element,
|
|
33
|
+
event,
|
|
34
|
+
element,
|
|
35
|
+
state,
|
|
36
|
+
context,
|
|
37
|
+
options
|
|
38
|
+
)
|
|
39
|
+
if (result && typeof result.then === 'function') {
|
|
40
|
+
result.catch((err) => {
|
|
41
|
+
element.error = err
|
|
42
|
+
console.error('[DomQL] Async DOM event error:', err)
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
element.error = err
|
|
47
|
+
console.error('[DomQL] DOM event error:', err)
|
|
48
|
+
if (context?.strictMode) throw err
|
|
40
49
|
}
|
|
41
50
|
}
|
|
42
51
|
|
package/mixins/html.js
CHANGED
|
@@ -7,7 +7,7 @@ import { exec } from '@domql/utils'
|
|
|
7
7
|
* an original one as a child
|
|
8
8
|
*/
|
|
9
9
|
export function html (param, element, node) {
|
|
10
|
-
const prop = exec(element?.props?.html
|
|
10
|
+
const prop = exec(param ?? element?.props?.html, element)
|
|
11
11
|
const { __ref } = element
|
|
12
12
|
if (prop !== __ref.__html) {
|
|
13
13
|
if (node.nodeName === 'SVG') node.textContent = prop
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -8,29 +8,23 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/esm/index.js",
|
|
11
|
-
"require": "./dist/cjs/index.js"
|
|
12
|
-
"browser": "./dist/esm/index.js",
|
|
13
|
-
"default": "./dist/esm/index.js"
|
|
11
|
+
"require": "./dist/cjs/index.js"
|
|
14
12
|
},
|
|
15
13
|
"./event": {
|
|
16
14
|
"import": "./dist/esm/event/index.js",
|
|
17
|
-
"require": "./dist/cjs/event/index.js"
|
|
18
|
-
"default": "./dist/esm/event/index.js"
|
|
15
|
+
"require": "./dist/cjs/event/index.js"
|
|
19
16
|
},
|
|
20
17
|
"./render": {
|
|
21
18
|
"import": "./dist/esm/render/index.js",
|
|
22
|
-
"require": "./dist/cjs/render/index.js"
|
|
23
|
-
"default": "./dist/esm/render/index.js"
|
|
19
|
+
"require": "./dist/cjs/render/index.js"
|
|
24
20
|
},
|
|
25
21
|
"./*.js": {
|
|
26
22
|
"import": "./dist/esm/*.js",
|
|
27
|
-
"require": "./dist/cjs/*.js"
|
|
28
|
-
"default": "./dist/esm/*.js"
|
|
23
|
+
"require": "./dist/cjs/*.js"
|
|
29
24
|
},
|
|
30
25
|
"./*": {
|
|
31
26
|
"import": "./dist/esm/*.js",
|
|
32
|
-
"require": "./dist/cjs/*.js"
|
|
33
|
-
"default": "./dist/esm/*.js"
|
|
27
|
+
"require": "./dist/cjs/*.js"
|
|
34
28
|
}
|
|
35
29
|
},
|
|
36
30
|
"source": "index.js",
|
|
@@ -52,10 +46,10 @@
|
|
|
52
46
|
"build:iife": "cross-env NODE_ENV=$NODE_ENV esbuild index.js --bundle --target=es2020 --format=iife --global-name=DomqlElement --outfile=dist/iife/index.js --define:process.env.NODE_ENV=process.env.NODE_ENV"
|
|
53
47
|
},
|
|
54
48
|
"dependencies": {
|
|
55
|
-
"@domql/report": "^3.
|
|
56
|
-
"@domql/state": "^3.
|
|
57
|
-
"@domql/utils": "^3.
|
|
58
|
-
"attrs-in-props": "^3.
|
|
49
|
+
"@domql/report": "^3.6.1",
|
|
50
|
+
"@domql/state": "^3.6.1",
|
|
51
|
+
"@domql/utils": "^3.6.1",
|
|
52
|
+
"attrs-in-props": "^3.6.1"
|
|
59
53
|
},
|
|
60
54
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
61
55
|
"devDependencies": {
|
|
@@ -64,5 +58,8 @@
|
|
|
64
58
|
"browser": "./dist/esm/index.js",
|
|
65
59
|
"unpkg": "./dist/iife/index.js",
|
|
66
60
|
"jsdelivr": "./dist/iife/index.js",
|
|
67
|
-
"sideEffects": false
|
|
61
|
+
"sideEffects": false,
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
}
|
|
68
65
|
}
|
package/set.js
CHANGED
|
@@ -130,7 +130,7 @@ export const set = function (params, options = {}, el) {
|
|
|
130
130
|
return
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
if (!params) return element
|
|
133
|
+
if (!params || typeof params !== 'object') return element
|
|
134
134
|
|
|
135
135
|
let { childExtends, props, tag } = params
|
|
136
136
|
if (!props) props = params.props = {}
|
package/update.js
CHANGED
|
@@ -288,6 +288,43 @@ export const update = function (params = {}, opts) {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
const findSiblingAttachOptions = (element, parent) => {
|
|
292
|
+
const { __children } = parent.__ref || {}
|
|
293
|
+
if (!__children) return false
|
|
294
|
+
|
|
295
|
+
const currentIndex = __children.indexOf(element.key)
|
|
296
|
+
|
|
297
|
+
// Walk backwards to find nearest previous sibling with a DOM node
|
|
298
|
+
let previousNode
|
|
299
|
+
for (let i = currentIndex - 1; i >= 0; i--) {
|
|
300
|
+
const sibling = parent[__children[i]]
|
|
301
|
+
if (sibling?.node?.parentNode) {
|
|
302
|
+
previousNode = sibling.node
|
|
303
|
+
break
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (previousNode) {
|
|
308
|
+
return { position: 'after', node: previousNode }
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Walk forwards to find nearest next sibling with a DOM node
|
|
312
|
+
let nextNode
|
|
313
|
+
for (let i = currentIndex + 1; i < __children.length; i++) {
|
|
314
|
+
const sibling = parent[__children[i]]
|
|
315
|
+
if (sibling?.node?.parentNode) {
|
|
316
|
+
nextNode = sibling.node
|
|
317
|
+
break
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (nextNode) {
|
|
322
|
+
return { position: 'before', node: nextNode }
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return false
|
|
326
|
+
}
|
|
327
|
+
|
|
291
328
|
const checkIfOnUpdate = (element, parent, options) => {
|
|
292
329
|
if ((!isFunction(element.if) && !isFunction(element.props?.if)) || !parent) {
|
|
293
330
|
return
|
|
@@ -331,18 +368,7 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
331
368
|
element[contentKey] = element[contentKey].parseDeep()
|
|
332
369
|
}
|
|
333
370
|
|
|
334
|
-
const
|
|
335
|
-
const previousNode = previousElement?.node // document.body.contains(previousElement.node)
|
|
336
|
-
const hasPrevious = previousNode?.parentNode // document.body.contains(previousElement.node)
|
|
337
|
-
|
|
338
|
-
const nextElement = element.nextElement()
|
|
339
|
-
const nextNode = nextElement?.node // document.body.contains(previousElement.node)
|
|
340
|
-
const hasNext = nextNode?.parentNode
|
|
341
|
-
|
|
342
|
-
const attachOptions = (hasPrevious || hasNext) && {
|
|
343
|
-
position: hasPrevious ? 'after' : hasNext ? 'before' : null,
|
|
344
|
-
node: (hasPrevious && previousNode) || (hasNext && nextNode)
|
|
345
|
-
}
|
|
371
|
+
const attachOptions = findSiblingAttachOptions(element, parent)
|
|
346
372
|
|
|
347
373
|
delete element.__ref
|
|
348
374
|
delete element.parent
|