@domql/element 3.7.0 → 3.7.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/dist/cjs/event/on.js +2 -15
- package/dist/cjs/mixins/attr.js +4 -1
- package/dist/cjs/mixins/html.js +4 -1
- package/dist/cjs/utils/propEvents.js +10 -5
- package/dist/esm/event/on.js +3 -16
- package/dist/esm/mixins/attr.js +5 -2
- package/dist/esm/mixins/html.js +5 -2
- package/dist/esm/utils/propEvents.js +11 -6
- package/dist/iife/index.js +115 -47
- package/event/on.js +3 -19
- package/mixins/attr.js +5 -2
- package/mixins/html.js +5 -2
- package/package.json +5 -5
- package/utils/propEvents.js +11 -6
package/dist/cjs/event/on.js
CHANGED
|
@@ -36,7 +36,7 @@ const getOnOrPropsEvent = (param, element) => {
|
|
|
36
36
|
return props[propKey];
|
|
37
37
|
};
|
|
38
38
|
const registerNodeEvent = (param, element, node, options) => {
|
|
39
|
-
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
39
|
+
const appliedFunction = (0, import_utils.resolveHandler)(getOnOrPropsEvent(param, element), element);
|
|
40
40
|
if ((0, import_utils.isFunction)(appliedFunction)) {
|
|
41
41
|
const { __ref: ref } = element;
|
|
42
42
|
if (!ref.__eventListeners) ref.__eventListeners = {};
|
|
@@ -71,22 +71,9 @@ const registerNodeEvent = (param, element, node, options) => {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
const applyEventsOnNode = (element, options) => {
|
|
74
|
-
const { node, on
|
|
75
|
-
const handled = /* @__PURE__ */ new Set();
|
|
74
|
+
const { node, on } = element;
|
|
76
75
|
for (const param in on) {
|
|
77
76
|
if (import_utils.DOMQL_EVENTS.has(param)) continue;
|
|
78
|
-
handled.add(param);
|
|
79
77
|
registerNodeEvent(param, element, node, options);
|
|
80
78
|
}
|
|
81
|
-
if (props) {
|
|
82
|
-
for (const key in props) {
|
|
83
|
-
if (key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && (0, import_utils.isFunction)(props[key])) {
|
|
84
|
-
const thirdChar = key[2];
|
|
85
|
-
if (thirdChar !== thirdChar.toUpperCase()) continue;
|
|
86
|
-
const eventName = thirdChar.toLowerCase() + key.slice(3);
|
|
87
|
-
if (handled.has(eventName) || import_utils.DOMQL_EVENTS.has(eventName)) continue;
|
|
88
|
-
registerNodeEvent(eventName, element, node, options);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
79
|
};
|
package/dist/cjs/mixins/attr.js
CHANGED
|
@@ -32,7 +32,10 @@ function attr(params, element, node) {
|
|
|
32
32
|
const attrs = (0, import_utils.exec)(params, element);
|
|
33
33
|
if (props.attr) (0, import_utils.deepMerge)(attrs, props.attr);
|
|
34
34
|
for (const attr2 in attrs) {
|
|
35
|
-
|
|
35
|
+
let val = (0, import_utils.exec)(attrs[attr2], element);
|
|
36
|
+
if ((0, import_utils.isString)(val) && val.includes("{{") && element.call) {
|
|
37
|
+
val = element.call("replaceLiteralsWithObjectFields", val, element.state);
|
|
38
|
+
}
|
|
36
39
|
if (val === __attr[attr2]) continue;
|
|
37
40
|
if (val !== false && val !== void 0 && val !== null && node.setAttribute) {
|
|
38
41
|
node.setAttribute(attr2, val);
|
package/dist/cjs/mixins/html.js
CHANGED
|
@@ -24,7 +24,10 @@ __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
|
-
|
|
27
|
+
let prop = (0, import_utils.exec)(param ?? element?.props?.html, element);
|
|
28
|
+
if ((0, import_utils.isString)(prop) && prop.includes("{{") && element.call) {
|
|
29
|
+
prop = element.call("replaceLiteralsWithObjectFields", prop, element.state);
|
|
30
|
+
}
|
|
28
31
|
const { __ref } = element;
|
|
29
32
|
if (prop !== __ref.__html) {
|
|
30
33
|
if (node.nodeName === "SVG") node.textContent = prop;
|
|
@@ -33,24 +33,29 @@ const propagateEventsFromProps = (element) => {
|
|
|
33
33
|
if ((0, import_utils.isFunction)(origEvent)) {
|
|
34
34
|
on[eventName] = (...args) => {
|
|
35
35
|
const originalEventRetunrs = origEvent(...args);
|
|
36
|
-
if (originalEventRetunrs !== false)
|
|
36
|
+
if (originalEventRetunrs !== false) {
|
|
37
|
+
if ((0, import_utils.isFunction)(funcFromProps)) return funcFromProps(...args);
|
|
38
|
+
}
|
|
37
39
|
};
|
|
38
40
|
} else on[eventName] = funcFromProps;
|
|
39
41
|
}
|
|
40
42
|
};
|
|
41
43
|
const propagateEventsFromElement = (element) => {
|
|
42
44
|
const { on } = element;
|
|
45
|
+
const pluginActive = (0, import_utils.hasHandlerPlugin)(element.context);
|
|
43
46
|
for (const param in element) {
|
|
44
47
|
if (param.charCodeAt(0) !== 111 || param.charCodeAt(1) !== 110 || !Object.prototype.hasOwnProperty.call(element, param)) continue;
|
|
45
|
-
const
|
|
46
|
-
if (!(0, import_utils.isFunction)(
|
|
48
|
+
const handler = element[param];
|
|
49
|
+
if (!(0, import_utils.isFunction)(handler) && !(pluginActive && handler != null)) continue;
|
|
47
50
|
const eventName = (0, import_utils.lowercaseFirstLetter)(param.slice(2));
|
|
48
51
|
const origEvent = on[eventName];
|
|
49
52
|
if ((0, import_utils.isFunction)(origEvent)) {
|
|
50
53
|
on[eventName] = (...args) => {
|
|
51
54
|
const ret = origEvent(...args);
|
|
52
|
-
if (ret !== false)
|
|
55
|
+
if (ret !== false) {
|
|
56
|
+
if ((0, import_utils.isFunction)(handler)) return handler(...args);
|
|
57
|
+
}
|
|
53
58
|
};
|
|
54
|
-
} else on[eventName] =
|
|
59
|
+
} else on[eventName] = handler;
|
|
55
60
|
}
|
|
56
61
|
};
|
package/dist/esm/event/on.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DOMQL_EVENTS, isFunction } from "@domql/utils";
|
|
1
|
+
import { DOMQL_EVENTS, isFunction, resolveHandler } from "@domql/utils";
|
|
2
2
|
import { applyEvent, triggerEventOn, applyEventUpdate, triggerEventOnUpdate } from "@domql/utils";
|
|
3
3
|
const getOnOrPropsEvent = (param, element) => {
|
|
4
4
|
const onEvent = element.on?.[param];
|
|
@@ -9,7 +9,7 @@ const getOnOrPropsEvent = (param, element) => {
|
|
|
9
9
|
return props[propKey];
|
|
10
10
|
};
|
|
11
11
|
const registerNodeEvent = (param, element, node, options) => {
|
|
12
|
-
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
12
|
+
const appliedFunction = resolveHandler(getOnOrPropsEvent(param, element), element);
|
|
13
13
|
if (isFunction(appliedFunction)) {
|
|
14
14
|
const { __ref: ref } = element;
|
|
15
15
|
if (!ref.__eventListeners) ref.__eventListeners = {};
|
|
@@ -44,24 +44,11 @@ const registerNodeEvent = (param, element, node, options) => {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
const applyEventsOnNode = (element, options) => {
|
|
47
|
-
const { node, on
|
|
48
|
-
const handled = /* @__PURE__ */ new Set();
|
|
47
|
+
const { node, on } = element;
|
|
49
48
|
for (const param in on) {
|
|
50
49
|
if (DOMQL_EVENTS.has(param)) continue;
|
|
51
|
-
handled.add(param);
|
|
52
50
|
registerNodeEvent(param, element, node, options);
|
|
53
51
|
}
|
|
54
|
-
if (props) {
|
|
55
|
-
for (const key in props) {
|
|
56
|
-
if (key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && isFunction(props[key])) {
|
|
57
|
-
const thirdChar = key[2];
|
|
58
|
-
if (thirdChar !== thirdChar.toUpperCase()) continue;
|
|
59
|
-
const eventName = thirdChar.toLowerCase() + key.slice(3);
|
|
60
|
-
if (handled.has(eventName) || DOMQL_EVENTS.has(eventName)) continue;
|
|
61
|
-
registerNodeEvent(eventName, element, node, options);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
52
|
};
|
|
66
53
|
export {
|
|
67
54
|
applyEvent,
|
package/dist/esm/mixins/attr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { deepMerge, exec, isNot } from "@domql/utils";
|
|
1
|
+
import { deepMerge, exec, isNot, isString } from "@domql/utils";
|
|
2
2
|
import { report } from "@domql/report";
|
|
3
3
|
function attr(params, element, node) {
|
|
4
4
|
const { __ref: ref, props } = element;
|
|
@@ -8,7 +8,10 @@ function attr(params, element, node) {
|
|
|
8
8
|
const attrs = exec(params, element);
|
|
9
9
|
if (props.attr) deepMerge(attrs, props.attr);
|
|
10
10
|
for (const attr2 in attrs) {
|
|
11
|
-
|
|
11
|
+
let val = exec(attrs[attr2], element);
|
|
12
|
+
if (isString(val) && val.includes("{{") && element.call) {
|
|
13
|
+
val = element.call("replaceLiteralsWithObjectFields", val, element.state);
|
|
14
|
+
}
|
|
12
15
|
if (val === __attr[attr2]) continue;
|
|
13
16
|
if (val !== false && val !== void 0 && val !== null && node.setAttribute) {
|
|
14
17
|
node.setAttribute(attr2, val);
|
package/dist/esm/mixins/html.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { exec } from "@domql/utils";
|
|
1
|
+
import { exec, isString } from "@domql/utils";
|
|
2
2
|
function html(param, element, node) {
|
|
3
|
-
|
|
3
|
+
let prop = exec(param ?? element?.props?.html, element);
|
|
4
|
+
if (isString(prop) && prop.includes("{{") && element.call) {
|
|
5
|
+
prop = element.call("replaceLiteralsWithObjectFields", prop, element.state);
|
|
6
|
+
}
|
|
4
7
|
const { __ref } = element;
|
|
5
8
|
if (prop !== __ref.__html) {
|
|
6
9
|
if (node.nodeName === "SVG") node.textContent = prop;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFunction, lowercaseFirstLetter } from "@domql/utils";
|
|
1
|
+
import { isFunction, hasHandlerPlugin, lowercaseFirstLetter } from "@domql/utils";
|
|
2
2
|
const propagateEventsFromProps = (element) => {
|
|
3
3
|
const { props, on } = element;
|
|
4
4
|
for (const v in props) {
|
|
@@ -9,25 +9,30 @@ const propagateEventsFromProps = (element) => {
|
|
|
9
9
|
if (isFunction(origEvent)) {
|
|
10
10
|
on[eventName] = (...args) => {
|
|
11
11
|
const originalEventRetunrs = origEvent(...args);
|
|
12
|
-
if (originalEventRetunrs !== false)
|
|
12
|
+
if (originalEventRetunrs !== false) {
|
|
13
|
+
if (isFunction(funcFromProps)) return funcFromProps(...args);
|
|
14
|
+
}
|
|
13
15
|
};
|
|
14
16
|
} else on[eventName] = funcFromProps;
|
|
15
17
|
}
|
|
16
18
|
};
|
|
17
19
|
const propagateEventsFromElement = (element) => {
|
|
18
20
|
const { on } = element;
|
|
21
|
+
const pluginActive = hasHandlerPlugin(element.context);
|
|
19
22
|
for (const param in element) {
|
|
20
23
|
if (param.charCodeAt(0) !== 111 || param.charCodeAt(1) !== 110 || !Object.prototype.hasOwnProperty.call(element, param)) continue;
|
|
21
|
-
const
|
|
22
|
-
if (!isFunction(
|
|
24
|
+
const handler = element[param];
|
|
25
|
+
if (!isFunction(handler) && !(pluginActive && handler != null)) continue;
|
|
23
26
|
const eventName = lowercaseFirstLetter(param.slice(2));
|
|
24
27
|
const origEvent = on[eventName];
|
|
25
28
|
if (isFunction(origEvent)) {
|
|
26
29
|
on[eventName] = (...args) => {
|
|
27
30
|
const ret = origEvent(...args);
|
|
28
|
-
if (ret !== false)
|
|
31
|
+
if (ret !== false) {
|
|
32
|
+
if (isFunction(handler)) return handler(...args);
|
|
33
|
+
}
|
|
29
34
|
};
|
|
30
|
-
} else on[eventName] =
|
|
35
|
+
} else on[eventName] = handler;
|
|
31
36
|
}
|
|
32
37
|
};
|
|
33
38
|
export {
|
package/dist/iife/index.js
CHANGED
|
@@ -631,8 +631,38 @@ var DomqlElement = (() => {
|
|
|
631
631
|
});
|
|
632
632
|
|
|
633
633
|
// ../utils/dist/esm/function.js
|
|
634
|
+
var hasHandlerPlugin, resolveHandler, runPluginHook;
|
|
634
635
|
var init_function = __esm({
|
|
635
636
|
"../utils/dist/esm/function.js"() {
|
|
637
|
+
hasHandlerPlugin = (ctx) => {
|
|
638
|
+
const plugins = ctx?.plugins;
|
|
639
|
+
if (!plugins || !plugins.length) return false;
|
|
640
|
+
for (const plugin of plugins) {
|
|
641
|
+
if (plugin.resolveHandler) return true;
|
|
642
|
+
}
|
|
643
|
+
return false;
|
|
644
|
+
};
|
|
645
|
+
resolveHandler = (handler, element) => {
|
|
646
|
+
if (typeof handler === "function") return handler;
|
|
647
|
+
const plugins = element?.context?.plugins;
|
|
648
|
+
if (!plugins) return handler;
|
|
649
|
+
for (const plugin of plugins) {
|
|
650
|
+
if (plugin.resolveHandler) {
|
|
651
|
+
const resolved = plugin.resolveHandler(handler, element);
|
|
652
|
+
if (typeof resolved === "function") return resolved;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return handler;
|
|
656
|
+
};
|
|
657
|
+
runPluginHook = (hookName, element, ...args) => {
|
|
658
|
+
const plugins = element?.context?.plugins;
|
|
659
|
+
if (!plugins) return;
|
|
660
|
+
for (const plugin of plugins) {
|
|
661
|
+
if (typeof plugin[hookName] === "function") {
|
|
662
|
+
plugin[hookName](element, ...args);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
};
|
|
636
666
|
}
|
|
637
667
|
});
|
|
638
668
|
|
|
@@ -1050,14 +1080,17 @@ var DomqlElement = (() => {
|
|
|
1050
1080
|
}
|
|
1051
1081
|
return element;
|
|
1052
1082
|
};
|
|
1053
|
-
trackSourcemapDeep = (sourcemap, obj, sourceName) => {
|
|
1083
|
+
trackSourcemapDeep = (sourcemap, obj, sourceName, seen) => {
|
|
1084
|
+
if (!seen) seen = /* @__PURE__ */ new WeakSet();
|
|
1085
|
+
if (seen.has(obj)) return;
|
|
1086
|
+
seen.add(obj);
|
|
1054
1087
|
for (const key in obj) {
|
|
1055
1088
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
1056
1089
|
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
1057
1090
|
const val = obj[key];
|
|
1058
1091
|
if (isObject(val) && !isArray(val)) {
|
|
1059
1092
|
sourcemap[key] = sourcemap[key] || {};
|
|
1060
|
-
trackSourcemapDeep(sourcemap[key], val, sourceName);
|
|
1093
|
+
trackSourcemapDeep(sourcemap[key], val, sourceName, seen);
|
|
1061
1094
|
} else {
|
|
1062
1095
|
sourcemap[key] = sourceName;
|
|
1063
1096
|
}
|
|
@@ -1255,7 +1288,9 @@ var DomqlElement = (() => {
|
|
|
1255
1288
|
if (isFunction(origEvent)) {
|
|
1256
1289
|
on[eventName] = (...args) => {
|
|
1257
1290
|
const originalEventRetunrs = origEvent(...args);
|
|
1258
|
-
if (originalEventRetunrs !== false)
|
|
1291
|
+
if (originalEventRetunrs !== false) {
|
|
1292
|
+
if (isFunction(funcFromProps)) return funcFromProps(...args);
|
|
1293
|
+
}
|
|
1259
1294
|
};
|
|
1260
1295
|
} else on[eventName] = funcFromProps;
|
|
1261
1296
|
}
|
|
@@ -1271,7 +1306,8 @@ var DomqlElement = (() => {
|
|
|
1271
1306
|
const cachedKeys = opts.cachedKeys || [];
|
|
1272
1307
|
for (const key in obj) {
|
|
1273
1308
|
const value = obj[key];
|
|
1274
|
-
const
|
|
1309
|
+
const isOnKey = key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && key[2] === key[2].toUpperCase();
|
|
1310
|
+
const isEventHandler = isOnKey && (isFunction(value) || value != null && hasHandlerPlugin(this.context));
|
|
1275
1311
|
if (isEventHandler) {
|
|
1276
1312
|
const eventName = lowercaseFirstLetter(key.slice(2));
|
|
1277
1313
|
if (obj.on) obj.on[eventName] = value;
|
|
@@ -1311,8 +1347,8 @@ var DomqlElement = (() => {
|
|
|
1311
1347
|
for (const key in obj.props) {
|
|
1312
1348
|
const value = obj.props[key];
|
|
1313
1349
|
const isEvent = key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110;
|
|
1314
|
-
const
|
|
1315
|
-
if (isEvent &&
|
|
1350
|
+
const isHandler = isFunction(value) || value != null && hasHandlerPlugin(this.context);
|
|
1351
|
+
if (isEvent && isHandler) {
|
|
1316
1352
|
addEventFromProps(key, obj);
|
|
1317
1353
|
delete obj.props[key];
|
|
1318
1354
|
continue;
|
|
@@ -1363,6 +1399,7 @@ var DomqlElement = (() => {
|
|
|
1363
1399
|
init_object();
|
|
1364
1400
|
init_types();
|
|
1365
1401
|
init_string();
|
|
1402
|
+
init_function();
|
|
1366
1403
|
RE_UPPER = /^[A-Z]/;
|
|
1367
1404
|
RE_DIGITS = /^\d+$/;
|
|
1368
1405
|
CSS_SELECTOR_PREFIXES = /* @__PURE__ */ new Set([":", "@", "[", "*", "+", "~", "&", ">", "$", "-", ".", "!"]);
|
|
@@ -1786,6 +1823,7 @@ var DomqlElement = (() => {
|
|
|
1786
1823
|
var init_triggerEvent = __esm({
|
|
1787
1824
|
"../utils/dist/esm/triggerEvent.js"() {
|
|
1788
1825
|
init_types();
|
|
1826
|
+
init_function();
|
|
1789
1827
|
getOnOrPropsEvent = (param, element) => {
|
|
1790
1828
|
const onEvent = element.on?.[param];
|
|
1791
1829
|
if (onEvent) return onEvent;
|
|
@@ -1795,6 +1833,7 @@ var DomqlElement = (() => {
|
|
|
1795
1833
|
return props[propKey];
|
|
1796
1834
|
};
|
|
1797
1835
|
applyEvent = (param, element, state2, context, options) => {
|
|
1836
|
+
param = resolveHandler(param, element);
|
|
1798
1837
|
if (!isFunction(param)) return;
|
|
1799
1838
|
try {
|
|
1800
1839
|
const result = param.call(
|
|
@@ -1821,6 +1860,7 @@ var DomqlElement = (() => {
|
|
|
1821
1860
|
if (!element) {
|
|
1822
1861
|
throw new Error("Element is required");
|
|
1823
1862
|
}
|
|
1863
|
+
runPluginHook(param, element, options);
|
|
1824
1864
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
1825
1865
|
if (appliedFunction) {
|
|
1826
1866
|
const { state: state2, context } = element;
|
|
@@ -1828,6 +1868,7 @@ var DomqlElement = (() => {
|
|
|
1828
1868
|
}
|
|
1829
1869
|
};
|
|
1830
1870
|
applyEventUpdate = (param, updatedObj, element, state2, context, options) => {
|
|
1871
|
+
param = resolveHandler(param, element);
|
|
1831
1872
|
if (!isFunction(param)) return;
|
|
1832
1873
|
try {
|
|
1833
1874
|
const result = param.call(
|
|
@@ -1852,6 +1893,7 @@ var DomqlElement = (() => {
|
|
|
1852
1893
|
}
|
|
1853
1894
|
};
|
|
1854
1895
|
triggerEventOnUpdate = (param, updatedObj, element, options) => {
|
|
1896
|
+
runPluginHook(param, element, updatedObj, options);
|
|
1855
1897
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
1856
1898
|
if (appliedFunction) {
|
|
1857
1899
|
const { state: state2, context } = element;
|
|
@@ -2307,13 +2349,14 @@ var DomqlElement = (() => {
|
|
|
2307
2349
|
createAdapter: () => createAdapter,
|
|
2308
2350
|
default: () => fetch_default,
|
|
2309
2351
|
executeFetch: () => executeFetch,
|
|
2352
|
+
fetchPlugin: () => fetchPlugin,
|
|
2310
2353
|
initAdapterAuth: () => initAdapterAuth,
|
|
2311
2354
|
parseDuration: () => parseDuration,
|
|
2312
2355
|
queryClient: () => queryClient,
|
|
2313
2356
|
registerAdapter: () => registerAdapter,
|
|
2314
2357
|
resolveDb: () => resolveDb
|
|
2315
2358
|
});
|
|
2316
|
-
var ADAPTER_METHODS, BUILTIN_ADAPTERS, registerAdapter, createAdapter, resolveDb, parseDuration, cacheStore, querySubscribers, activeQueries, buildCacheKey, getCacheEntry, setCacheEntry, invalidateCache, removeCache, parseCacheConfig, gcTimer, startGC, DEFAULT_RETRY, DEFAULT_RETRY_DELAY, resolveRetryConfig, withRetry, globalListeners, globalListenersAttached, attachGlobalListeners, resolveFetchConfig, resolveParamsSync, resolveParams, initAdapterAuth, resolveAdapter, triggerCallback, collectFormData, updateElementState, setFetchStatus, runFetch, bindEvent, bindAutoRefetch, applyOptimisticUpdate, rollbackOptimistic, runMutation, executeFetch, queryClient, fetch_default;
|
|
2359
|
+
var ADAPTER_METHODS, BUILTIN_ADAPTERS, registerAdapter, createAdapter, resolveDb, parseDuration, cacheStore, querySubscribers, activeQueries, buildCacheKey, getCacheEntry, setCacheEntry, invalidateCache, removeCache, parseCacheConfig, gcTimer, startGC, DEFAULT_RETRY, DEFAULT_RETRY_DELAY, resolveRetryConfig, withRetry, globalListeners, globalListenersAttached, attachGlobalListeners, resolveFetchConfig, resolveParamsSync, resolveLanguage, resolveParams, initAdapterAuth, resolveAdapter, triggerCallback, collectFormData, updateElementState, setFetchStatus, runFetch, bindEvent, bindAutoRefetch, applyOptimisticUpdate, rollbackOptimistic, runMutation, executeFetch, queryClient, fetchPlugin, fetch_default;
|
|
2317
2360
|
var init_fetch = __esm({
|
|
2318
2361
|
"../../plugins/fetch/index.js"() {
|
|
2319
2362
|
"use strict";
|
|
@@ -2509,13 +2552,23 @@ var DomqlElement = (() => {
|
|
|
2509
2552
|
if (!params || isFunction(params)) return params;
|
|
2510
2553
|
return params;
|
|
2511
2554
|
};
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
if (
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2555
|
+
resolveLanguage = (element, context) => {
|
|
2556
|
+
const root = element?.state?.root || context?.state?.root;
|
|
2557
|
+
if (root?.lang) return root.lang;
|
|
2558
|
+
return void 0;
|
|
2559
|
+
};
|
|
2560
|
+
resolveParams = (params, element, context) => {
|
|
2561
|
+
let resolved;
|
|
2562
|
+
if (!params) {
|
|
2563
|
+
resolved = void 0;
|
|
2564
|
+
} else if (isFunction(params)) {
|
|
2565
|
+
resolved = params(element, element.state);
|
|
2566
|
+
} else {
|
|
2567
|
+
resolved = {};
|
|
2568
|
+
for (const key in params) {
|
|
2569
|
+
const val = params[key];
|
|
2570
|
+
resolved[key] = isFunction(val) ? val(element, element.state) : val;
|
|
2571
|
+
}
|
|
2519
2572
|
}
|
|
2520
2573
|
return resolved;
|
|
2521
2574
|
};
|
|
@@ -2553,7 +2606,7 @@ var DomqlElement = (() => {
|
|
|
2553
2606
|
db.__resolving = resolveDb(db);
|
|
2554
2607
|
const resolved = await db.__resolving;
|
|
2555
2608
|
db.__resolved = resolved;
|
|
2556
|
-
context.
|
|
2609
|
+
context.fetch = resolved;
|
|
2557
2610
|
delete db.__resolving;
|
|
2558
2611
|
if (db.auth !== false) await initAdapterAuth(resolved, context);
|
|
2559
2612
|
return resolved;
|
|
@@ -2601,7 +2654,7 @@ var DomqlElement = (() => {
|
|
|
2601
2654
|
ref.__fetchError = status.error;
|
|
2602
2655
|
};
|
|
2603
2656
|
runFetch = async (config, element, context, opts = {}) => {
|
|
2604
|
-
const db = context?.
|
|
2657
|
+
const db = context?.fetch;
|
|
2605
2658
|
if (!db) return;
|
|
2606
2659
|
if (config.enabled === false) return;
|
|
2607
2660
|
if (isFunction(config.enabled) && !config.enabled(element, element.state)) return;
|
|
@@ -2641,7 +2694,7 @@ var DomqlElement = (() => {
|
|
|
2641
2694
|
const q = element.getQuery(adapter.name || "paths");
|
|
2642
2695
|
if (q) select = q.select || q.length && q.join(",") || void 0;
|
|
2643
2696
|
}
|
|
2644
|
-
const params = resolveParams(rawParams, element);
|
|
2697
|
+
const params = resolveParams(rawParams, element, context);
|
|
2645
2698
|
const cacheConfig = parseCacheConfig(cacheRaw);
|
|
2646
2699
|
const retryConfig = resolveRetryConfig(config);
|
|
2647
2700
|
const cacheKey = cacheConfig ? cacheRaw?.key || `${from}:${method}:${JSON.stringify(params || "")}${infinite ? ":infinite" : ""}${page ? ":p" + JSON.stringify(page) : ""}` : null;
|
|
@@ -2711,6 +2764,10 @@ var DomqlElement = (() => {
|
|
|
2711
2764
|
const fn = adapter[method];
|
|
2712
2765
|
if (!isFunction(fn)) return { data: null, error: { message: `Method "${method}" not found on adapter` } };
|
|
2713
2766
|
const request2 = { from, select, params, single, limit, offset, order, headers, baseUrl };
|
|
2767
|
+
const lang = resolveLanguage(element, context);
|
|
2768
|
+
if (lang) {
|
|
2769
|
+
request2.headers = { ...request2.headers, "Accept-Language": lang };
|
|
2770
|
+
}
|
|
2714
2771
|
if (page !== void 0) {
|
|
2715
2772
|
if (isObject(page)) {
|
|
2716
2773
|
if (page.offset !== void 0) request2.offset = page.offset;
|
|
@@ -2893,7 +2950,7 @@ var DomqlElement = (() => {
|
|
|
2893
2950
|
}
|
|
2894
2951
|
};
|
|
2895
2952
|
runMutation = async (config, element, context) => {
|
|
2896
|
-
const db = context?.
|
|
2953
|
+
const db = context?.fetch;
|
|
2897
2954
|
if (!db) return;
|
|
2898
2955
|
const adapter = await resolveAdapter(db, context);
|
|
2899
2956
|
if (!adapter) return;
|
|
@@ -2930,7 +2987,11 @@ var DomqlElement = (() => {
|
|
|
2930
2987
|
const fn = adapter[method];
|
|
2931
2988
|
if (!isFunction(fn)) return;
|
|
2932
2989
|
const request2 = { from, data: mutationData, headers, baseUrl };
|
|
2933
|
-
if (config.params) request2.params = resolveParams(config.params, element);
|
|
2990
|
+
if (config.params) request2.params = resolveParams(config.params, element, context);
|
|
2991
|
+
const lang = resolveLanguage(element, context);
|
|
2992
|
+
if (lang) {
|
|
2993
|
+
request2.headers = { ...request2.headers, "Accept-Language": lang };
|
|
2994
|
+
}
|
|
2934
2995
|
const retryConfig = resolveRetryConfig(config);
|
|
2935
2996
|
const result = await withRetry(() => fn(request2), retryConfig);
|
|
2936
2997
|
const { data: data2, error: error2 } = result || {};
|
|
@@ -2975,7 +3036,7 @@ var DomqlElement = (() => {
|
|
|
2975
3036
|
};
|
|
2976
3037
|
executeFetch = (param, element, state2, context) => {
|
|
2977
3038
|
if (!param) return;
|
|
2978
|
-
const db = context?.
|
|
3039
|
+
const db = context?.fetch;
|
|
2979
3040
|
if (!db) return;
|
|
2980
3041
|
const fetchProp = exec(param, element);
|
|
2981
3042
|
if (!fetchProp) return;
|
|
@@ -3061,7 +3122,7 @@ var DomqlElement = (() => {
|
|
|
3061
3122
|
setCacheEntry(key, data2, null);
|
|
3062
3123
|
},
|
|
3063
3124
|
prefetchQuery: async (config, context) => {
|
|
3064
|
-
const db = context?.
|
|
3125
|
+
const db = context?.fetch;
|
|
3065
3126
|
if (!db) return;
|
|
3066
3127
|
const adapter = await resolveAdapter(db, context);
|
|
3067
3128
|
if (!adapter) return;
|
|
@@ -3085,6 +3146,15 @@ var DomqlElement = (() => {
|
|
|
3085
3146
|
getCache: () => cacheStore,
|
|
3086
3147
|
clear: () => removeCache()
|
|
3087
3148
|
};
|
|
3149
|
+
fetchPlugin = {
|
|
3150
|
+
name: "fetch",
|
|
3151
|
+
// Hook into element creation to auto-execute fetch configs
|
|
3152
|
+
create(element) {
|
|
3153
|
+
const fetchProp = element.fetch || element.props?.fetch;
|
|
3154
|
+
if (!fetchProp) return;
|
|
3155
|
+
executeFetch(fetchProp, element, element.state, element.context);
|
|
3156
|
+
}
|
|
3157
|
+
};
|
|
3088
3158
|
fetch_default = executeFetch;
|
|
3089
3159
|
}
|
|
3090
3160
|
});
|
|
@@ -3384,18 +3454,18 @@ var DomqlElement = (() => {
|
|
|
3384
3454
|
const result = fn.call(this, ...args);
|
|
3385
3455
|
if (result && typeof result.then === "function") {
|
|
3386
3456
|
result.catch((err) => {
|
|
3387
|
-
this
|
|
3457
|
+
error.call(this, err);
|
|
3388
3458
|
});
|
|
3389
3459
|
}
|
|
3390
3460
|
return result;
|
|
3391
3461
|
} catch (err) {
|
|
3392
|
-
this
|
|
3462
|
+
error.call(this, err);
|
|
3393
3463
|
if (context?.strictMode) throw err;
|
|
3394
3464
|
}
|
|
3395
3465
|
}
|
|
3396
3466
|
async function getDB() {
|
|
3397
3467
|
const element = this;
|
|
3398
|
-
const db = element.context?.
|
|
3468
|
+
const db = element.context?.fetch;
|
|
3399
3469
|
if (!db) return null;
|
|
3400
3470
|
if (typeof db.select === "function") {
|
|
3401
3471
|
if (!db.__authInitialized && db.getSession) {
|
|
@@ -3416,7 +3486,7 @@ var DomqlElement = (() => {
|
|
|
3416
3486
|
db.__resolving = resolvePromise;
|
|
3417
3487
|
const resolved = await resolvePromise;
|
|
3418
3488
|
db.__resolved = resolved;
|
|
3419
|
-
element.context.
|
|
3489
|
+
element.context.fetch = resolved;
|
|
3420
3490
|
delete db.__resolving;
|
|
3421
3491
|
if (resolved.getSession) {
|
|
3422
3492
|
const { initAdapterAuth: initAdapterAuth2 } = await Promise.resolve().then(() => (init_fetch(), fetch_exports));
|
|
@@ -3797,7 +3867,7 @@ ${element}` : "";
|
|
|
3797
3867
|
return props[propKey];
|
|
3798
3868
|
};
|
|
3799
3869
|
var registerNodeEvent = (param, element, node, options) => {
|
|
3800
|
-
const appliedFunction = getOnOrPropsEvent2(param, element);
|
|
3870
|
+
const appliedFunction = resolveHandler(getOnOrPropsEvent2(param, element), element);
|
|
3801
3871
|
if (isFunction(appliedFunction)) {
|
|
3802
3872
|
const { __ref: ref } = element;
|
|
3803
3873
|
if (!ref.__eventListeners) ref.__eventListeners = {};
|
|
@@ -3832,24 +3902,11 @@ ${element}` : "";
|
|
|
3832
3902
|
}
|
|
3833
3903
|
};
|
|
3834
3904
|
var applyEventsOnNode = (element, options) => {
|
|
3835
|
-
const { node, on
|
|
3836
|
-
const handled = /* @__PURE__ */ new Set();
|
|
3905
|
+
const { node, on } = element;
|
|
3837
3906
|
for (const param in on) {
|
|
3838
3907
|
if (DOMQL_EVENTS.has(param)) continue;
|
|
3839
|
-
handled.add(param);
|
|
3840
3908
|
registerNodeEvent(param, element, node, options);
|
|
3841
3909
|
}
|
|
3842
|
-
if (props) {
|
|
3843
|
-
for (const key in props) {
|
|
3844
|
-
if (key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && isFunction(props[key])) {
|
|
3845
|
-
const thirdChar = key[2];
|
|
3846
|
-
if (thirdChar !== thirdChar.toUpperCase()) continue;
|
|
3847
|
-
const eventName = thirdChar.toLowerCase() + key.slice(3);
|
|
3848
|
-
if (handled.has(eventName) || DOMQL_EVENTS.has(eventName)) continue;
|
|
3849
|
-
registerNodeEvent(eventName, element, node, options);
|
|
3850
|
-
}
|
|
3851
|
-
}
|
|
3852
|
-
}
|
|
3853
3910
|
};
|
|
3854
3911
|
|
|
3855
3912
|
// event/can.js
|
|
@@ -3944,25 +4001,30 @@ ${element}` : "";
|
|
|
3944
4001
|
if (isFunction(origEvent)) {
|
|
3945
4002
|
on[eventName] = (...args) => {
|
|
3946
4003
|
const originalEventRetunrs = origEvent(...args);
|
|
3947
|
-
if (originalEventRetunrs !== false)
|
|
4004
|
+
if (originalEventRetunrs !== false) {
|
|
4005
|
+
if (isFunction(funcFromProps)) return funcFromProps(...args);
|
|
4006
|
+
}
|
|
3948
4007
|
};
|
|
3949
4008
|
} else on[eventName] = funcFromProps;
|
|
3950
4009
|
}
|
|
3951
4010
|
};
|
|
3952
4011
|
var propagateEventsFromElement = (element) => {
|
|
3953
4012
|
const { on } = element;
|
|
4013
|
+
const pluginActive = hasHandlerPlugin(element.context);
|
|
3954
4014
|
for (const param in element) {
|
|
3955
4015
|
if (param.charCodeAt(0) !== 111 || param.charCodeAt(1) !== 110 || !Object.prototype.hasOwnProperty.call(element, param)) continue;
|
|
3956
|
-
const
|
|
3957
|
-
if (!isFunction(
|
|
4016
|
+
const handler = element[param];
|
|
4017
|
+
if (!isFunction(handler) && !(pluginActive && handler != null)) continue;
|
|
3958
4018
|
const eventName = lowercaseFirstLetter(param.slice(2));
|
|
3959
4019
|
const origEvent = on[eventName];
|
|
3960
4020
|
if (isFunction(origEvent)) {
|
|
3961
4021
|
on[eventName] = (...args) => {
|
|
3962
4022
|
const ret = origEvent(...args);
|
|
3963
|
-
if (ret !== false)
|
|
4023
|
+
if (ret !== false) {
|
|
4024
|
+
if (isFunction(handler)) return handler(...args);
|
|
4025
|
+
}
|
|
3964
4026
|
};
|
|
3965
|
-
} else on[eventName] =
|
|
4027
|
+
} else on[eventName] = handler;
|
|
3966
4028
|
}
|
|
3967
4029
|
};
|
|
3968
4030
|
|
|
@@ -4240,7 +4302,10 @@ ${element}` : "";
|
|
|
4240
4302
|
const attrs = exec(params, element);
|
|
4241
4303
|
if (props.attr) deepMerge(attrs, props.attr);
|
|
4242
4304
|
for (const attr2 in attrs) {
|
|
4243
|
-
|
|
4305
|
+
let val = exec(attrs[attr2], element);
|
|
4306
|
+
if (isString(val) && val.includes("{{") && element.call) {
|
|
4307
|
+
val = element.call("replaceLiteralsWithObjectFields", val, element.state);
|
|
4308
|
+
}
|
|
4244
4309
|
if (val === __attr[attr2]) continue;
|
|
4245
4310
|
if (val !== false && val !== void 0 && val !== null && node.setAttribute) {
|
|
4246
4311
|
node.setAttribute(attr2, val);
|
|
@@ -4301,7 +4366,10 @@ ${element}` : "";
|
|
|
4301
4366
|
// mixins/html.js
|
|
4302
4367
|
init_esm();
|
|
4303
4368
|
function html(param, element, node) {
|
|
4304
|
-
|
|
4369
|
+
let prop = exec(param ?? element?.props?.html, element);
|
|
4370
|
+
if (isString(prop) && prop.includes("{{") && element.call) {
|
|
4371
|
+
prop = element.call("replaceLiteralsWithObjectFields", prop, element.state);
|
|
4372
|
+
}
|
|
4305
4373
|
const { __ref } = element;
|
|
4306
4374
|
if (prop !== __ref.__html) {
|
|
4307
4375
|
if (node.nodeName === "SVG") node.textContent = prop;
|
package/event/on.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { DOMQL_EVENTS, isFunction } from '@domql/utils'
|
|
3
|
+
import { DOMQL_EVENTS, isFunction, resolveHandler } from '@domql/utils'
|
|
4
4
|
|
|
5
5
|
// Re-export event trigger functions from @domql/utils (moved there to break circular dep)
|
|
6
6
|
export { applyEvent, triggerEventOn, applyEventUpdate, triggerEventOnUpdate } from '@domql/utils'
|
|
@@ -15,7 +15,7 @@ const getOnOrPropsEvent = (param, element) => {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const registerNodeEvent = (param, element, node, options) => {
|
|
18
|
-
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
18
|
+
const appliedFunction = resolveHandler(getOnOrPropsEvent(param, element), element)
|
|
19
19
|
if (isFunction(appliedFunction)) {
|
|
20
20
|
const { __ref: ref } = element
|
|
21
21
|
if (!ref.__eventListeners) ref.__eventListeners = {}
|
|
@@ -55,26 +55,10 @@ const registerNodeEvent = (param, element, node, options) => {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export const applyEventsOnNode = (element, options) => {
|
|
58
|
-
const { node, on
|
|
59
|
-
const handled = new Set()
|
|
58
|
+
const { node, on } = element
|
|
60
59
|
|
|
61
|
-
// Register events from on: { click: ..., input: ... }
|
|
62
60
|
for (const param in on) {
|
|
63
61
|
if (DOMQL_EVENTS.has(param)) continue
|
|
64
|
-
handled.add(param)
|
|
65
62
|
registerNodeEvent(param, element, node, options)
|
|
66
63
|
}
|
|
67
|
-
|
|
68
|
-
// Also pick up props.onClick, props.onInput, etc.
|
|
69
|
-
if (props) {
|
|
70
|
-
for (const key in props) {
|
|
71
|
-
if (key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && isFunction(props[key])) {
|
|
72
|
-
const thirdChar = key[2]
|
|
73
|
-
if (thirdChar !== thirdChar.toUpperCase()) continue
|
|
74
|
-
const eventName = thirdChar.toLowerCase() + key.slice(3)
|
|
75
|
-
if (handled.has(eventName) || DOMQL_EVENTS.has(eventName)) continue
|
|
76
|
-
registerNodeEvent(eventName, element, node, options)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
64
|
}
|
package/mixins/attr.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { deepMerge, exec, isNot } from '@domql/utils'
|
|
3
|
+
import { deepMerge, exec, isNot, isString } from '@domql/utils'
|
|
4
4
|
import { report } from '@domql/report'
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -14,7 +14,10 @@ export function attr (params, element, node) {
|
|
|
14
14
|
const attrs = exec(params, element)
|
|
15
15
|
if (props.attr) deepMerge(attrs, props.attr)
|
|
16
16
|
for (const attr in attrs) {
|
|
17
|
-
|
|
17
|
+
let val = exec(attrs[attr], element)
|
|
18
|
+
if (isString(val) && val.includes('{{') && element.call) {
|
|
19
|
+
val = element.call('replaceLiteralsWithObjectFields', val, element.state)
|
|
20
|
+
}
|
|
18
21
|
if (val === __attr[attr]) continue
|
|
19
22
|
if (
|
|
20
23
|
val !== false &&
|
package/mixins/html.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { exec } from '@domql/utils'
|
|
3
|
+
import { exec, isString } from '@domql/utils'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Appends raw HTML as content
|
|
7
7
|
* an original one as a child
|
|
8
8
|
*/
|
|
9
9
|
export function html (param, element, node) {
|
|
10
|
-
|
|
10
|
+
let prop = exec(param ?? element?.props?.html, element)
|
|
11
|
+
if (isString(prop) && prop.includes('{{') && element.call) {
|
|
12
|
+
prop = element.call('replaceLiteralsWithObjectFields', prop, element.state)
|
|
13
|
+
}
|
|
11
14
|
const { __ref } = element
|
|
12
15
|
if (prop !== __ref.__html) {
|
|
13
16
|
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.7.
|
|
3
|
+
"version": "3.7.4",
|
|
4
4
|
"license": "CC-BY-NC-4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
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"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@domql/report": "^3.7.
|
|
50
|
-
"@domql/state": "^3.7.
|
|
51
|
-
"@domql/utils": "^3.7.
|
|
52
|
-
"attrs-in-props": "^3.7.
|
|
49
|
+
"@domql/report": "^3.7.4",
|
|
50
|
+
"@domql/state": "^3.7.4",
|
|
51
|
+
"@domql/utils": "^3.7.4",
|
|
52
|
+
"attrs-in-props": "^3.7.4"
|
|
53
53
|
},
|
|
54
54
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
55
55
|
"devDependencies": {
|
package/utils/propEvents.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isFunction, lowercaseFirstLetter } from '@domql/utils'
|
|
3
|
+
import { isFunction, hasHandlerPlugin, lowercaseFirstLetter } from '@domql/utils'
|
|
4
4
|
|
|
5
5
|
export const propagateEventsFromProps = (element) => {
|
|
6
6
|
const { props, on } = element
|
|
@@ -12,7 +12,9 @@ export const propagateEventsFromProps = (element) => {
|
|
|
12
12
|
if (isFunction(origEvent)) {
|
|
13
13
|
on[eventName] = (...args) => {
|
|
14
14
|
const originalEventRetunrs = origEvent(...args)
|
|
15
|
-
if (originalEventRetunrs !== false)
|
|
15
|
+
if (originalEventRetunrs !== false) {
|
|
16
|
+
if (isFunction(funcFromProps)) return funcFromProps(...args)
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
19
|
} else on[eventName] = funcFromProps
|
|
18
20
|
}
|
|
@@ -20,17 +22,20 @@ export const propagateEventsFromProps = (element) => {
|
|
|
20
22
|
|
|
21
23
|
export const propagateEventsFromElement = (element) => {
|
|
22
24
|
const { on } = element
|
|
25
|
+
const pluginActive = hasHandlerPlugin(element.context)
|
|
23
26
|
for (const param in element) {
|
|
24
27
|
if (param.charCodeAt(0) !== 111 || param.charCodeAt(1) !== 110 || !Object.prototype.hasOwnProperty.call(element, param)) continue
|
|
25
|
-
const
|
|
26
|
-
if (!isFunction(
|
|
28
|
+
const handler = element[param]
|
|
29
|
+
if (!isFunction(handler) && !(pluginActive && handler != null)) continue
|
|
27
30
|
const eventName = lowercaseFirstLetter(param.slice(2))
|
|
28
31
|
const origEvent = on[eventName]
|
|
29
32
|
if (isFunction(origEvent)) {
|
|
30
33
|
on[eventName] = (...args) => {
|
|
31
34
|
const ret = origEvent(...args)
|
|
32
|
-
if (ret !== false)
|
|
35
|
+
if (ret !== false) {
|
|
36
|
+
if (isFunction(handler)) return handler(...args)
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
|
-
} else on[eventName] =
|
|
39
|
+
} else on[eventName] = handler
|
|
35
40
|
}
|
|
36
41
|
}
|