@domql/element 2.5.198 → 3.0.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/README.md +1 -1
- package/__tests__/checkIfOnUpdate.test.js +103 -0
- package/__tests__/children.test.js +213 -0
- package/__tests__/define.test.js +75 -0
- package/__tests__/inheritStateUpdates.test.js +79 -0
- package/__tests__/renderElement.test.js +131 -0
- package/__tests__/resetElement.test.js +44 -0
- package/__tests__/set.test.js +316 -0
- package/__tests__/throughExecProps.test.js +86 -0
- package/__tests__/throughInitialDefine.test.js +104 -0
- package/__tests__/throughInitialExec.test.js +92 -0
- package/__tests__/throughUpdatedDefine.test.js +92 -0
- package/__tests__/throughUpdatedExec.test.js +110 -0
- package/__tests__/tree.test.js +15 -0
- package/__tests__/update.test.js +253 -0
- package/children.js +105 -0
- package/create.js +125 -255
- package/dist/cjs/__tests__/checkIfOnUpdate.test.js +73 -0
- package/dist/cjs/__tests__/children.test.js +177 -0
- package/dist/cjs/__tests__/define.test.js +75 -0
- package/dist/cjs/__tests__/inheritStateUpdates.test.js +62 -0
- package/dist/cjs/__tests__/renderElement.test.js +138 -0
- package/dist/cjs/__tests__/resetElement.test.js +35 -0
- package/dist/cjs/__tests__/set.test.js +256 -0
- package/dist/cjs/__tests__/throughExecProps.test.js +62 -0
- package/dist/cjs/__tests__/throughInitialDefine.test.js +79 -0
- package/dist/cjs/__tests__/throughInitialExec.test.js +73 -0
- package/dist/cjs/__tests__/throughUpdatedDefine.test.js +69 -0
- package/dist/cjs/__tests__/throughUpdatedExec.test.js +84 -0
- package/dist/cjs/__tests__/tree.test.js +11 -0
- package/dist/cjs/__tests__/update.test.js +219 -0
- package/dist/cjs/children.js +87 -0
- package/dist/cjs/create.js +74 -215
- package/dist/cjs/define.js +1 -2
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/iterate.js +37 -30
- package/dist/cjs/methods/set.js +26 -25
- package/dist/cjs/methods/v2.js +7 -17
- package/dist/cjs/mixins/attr.js +7 -10
- package/dist/cjs/mixins/classList.js +8 -16
- package/dist/cjs/mixins/data.js +2 -4
- package/dist/cjs/mixins/html.js +2 -4
- package/dist/cjs/mixins/index.js +0 -4
- package/dist/cjs/mixins/registry.js +7 -67
- package/dist/cjs/mixins/scope.js +2 -3
- package/dist/cjs/mixins/state.js +4 -7
- package/dist/cjs/mixins/style.js +2 -4
- package/dist/cjs/mixins/text.js +5 -8
- package/dist/cjs/node.js +34 -30
- package/dist/cjs/set.js +112 -47
- package/dist/cjs/update.js +123 -92
- package/dist/cjs/utils/applyParam.js +3 -4
- package/dist/cjs/utils/index.js +8 -4
- package/dist/cjs/utils/onlyResolveExtends.js +14 -30
- package/dist/esm/__tests__/checkIfOnUpdate.test.js +73 -0
- package/dist/esm/__tests__/children.test.js +177 -0
- package/dist/esm/__tests__/define.test.js +53 -0
- package/dist/esm/__tests__/inheritStateUpdates.test.js +62 -0
- package/dist/esm/__tests__/renderElement.test.js +116 -0
- package/dist/esm/__tests__/resetElement.test.js +35 -0
- package/dist/esm/__tests__/set.test.js +256 -0
- package/dist/esm/__tests__/throughExecProps.test.js +62 -0
- package/dist/esm/__tests__/throughInitialDefine.test.js +79 -0
- package/dist/esm/__tests__/throughInitialExec.test.js +73 -0
- package/dist/esm/__tests__/throughUpdatedDefine.test.js +69 -0
- package/dist/esm/__tests__/throughUpdatedExec.test.js +84 -0
- package/dist/esm/__tests__/tree.test.js +11 -0
- package/dist/esm/__tests__/update.test.js +219 -0
- package/dist/esm/children.js +81 -0
- package/dist/esm/create.js +79 -226
- package/dist/esm/define.js +1 -2
- package/dist/esm/iterate.js +41 -33
- package/dist/esm/methods/set.js +5 -4
- package/dist/esm/methods/v2.js +7 -17
- package/dist/esm/mixins/attr.js +8 -11
- package/dist/esm/mixins/classList.js +8 -16
- package/dist/esm/mixins/data.js +3 -5
- package/dist/esm/mixins/html.js +2 -4
- package/dist/esm/mixins/index.js +0 -4
- package/dist/esm/mixins/registry.js +7 -67
- package/dist/esm/mixins/scope.js +2 -3
- package/dist/esm/mixins/state.js +5 -8
- package/dist/esm/mixins/style.js +2 -4
- package/dist/esm/mixins/text.js +6 -12
- package/dist/esm/node.js +25 -31
- package/dist/esm/set.js +112 -47
- package/dist/esm/update.js +127 -97
- package/dist/esm/utils/applyParam.js +3 -4
- package/dist/esm/utils/index.js +4 -3
- package/dist/esm/utils/onlyResolveExtends.js +22 -31
- package/iterate.js +44 -26
- package/methods/set.js +5 -4
- package/methods/v2.js +5 -4
- package/mixins/attr.js +13 -7
- package/mixins/classList.js +7 -2
- package/mixins/data.js +1 -1
- package/mixins/index.js +1 -6
- package/mixins/registry.js +6 -53
- package/mixins/scope.js +1 -1
- package/mixins/state.js +4 -5
- package/mixins/text.js +4 -7
- package/node.js +31 -28
- package/package.json +7 -6
- package/set.js +129 -41
- package/update.js +169 -89
- package/utils/applyParam.js +7 -4
- package/utils/index.js +1 -3
- package/utils/onlyResolveExtends.js +27 -16
- package/cache/index.js +0 -3
- package/cache/options.js +0 -4
- package/dist/cjs/cache/index.js +0 -24
- package/dist/cjs/cache/options.js +0 -26
- package/dist/cjs/extend.js +0 -85
- package/dist/cjs/methods/index.js +0 -353
- package/dist/cjs/mixins/content.js +0 -74
- package/dist/cjs/props/create.js +0 -98
- package/dist/cjs/props/ignore.js +0 -24
- package/dist/cjs/props/index.js +0 -21
- package/dist/cjs/props/inherit.js +0 -53
- package/dist/cjs/props/update.js +0 -37
- package/dist/cjs/utils/component.js +0 -77
- package/dist/cjs/utils/extendUtils.js +0 -142
- package/dist/cjs/utils/object.js +0 -179
- package/dist/cjs/utils/propEvents.js +0 -41
- package/dist/esm/cache/index.js +0 -4
- package/dist/esm/cache/options.js +0 -6
- package/dist/esm/extend.js +0 -71
- package/dist/esm/methods/index.js +0 -333
- package/dist/esm/mixins/content.js +0 -54
- package/dist/esm/props/create.js +0 -78
- package/dist/esm/props/ignore.js +0 -4
- package/dist/esm/props/index.js +0 -4
- package/dist/esm/props/inherit.js +0 -33
- package/dist/esm/props/update.js +0 -17
- package/dist/esm/utils/component.js +0 -65
- package/dist/esm/utils/extendUtils.js +0 -122
- package/dist/esm/utils/object.js +0 -159
- package/dist/esm/utils/propEvents.js +0 -21
- package/extend.js +0 -90
- package/methods/index.js +0 -317
- package/mixins/content.js +0 -55
- package/props/create.js +0 -87
- package/props/ignore.js +0 -3
- package/props/index.js +0 -6
- package/props/inherit.js +0 -35
- package/props/update.js +0 -17
- package/utils/component.js +0 -68
- package/utils/extendUtils.js +0 -134
- package/utils/object.js +0 -172
- package/utils/propEvents.js +0 -19
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
exec,
|
|
5
|
+
initProps,
|
|
6
|
+
isFunction,
|
|
7
|
+
isMethod,
|
|
8
|
+
isObject,
|
|
9
|
+
isUndefined
|
|
10
|
+
} from '@domql/utils'
|
|
4
11
|
import { create } from '..'
|
|
5
12
|
import { REGISTRY } from '../mixins/index.js'
|
|
6
|
-
import { applyVariant, isVariant } from '.'
|
|
7
|
-
import { isMethod } from '../methods'
|
|
8
13
|
import { addMethods } from '../methods/set'
|
|
9
14
|
import { createState } from '@domql/state'
|
|
10
15
|
import { detectTag } from '@domql/render'
|
|
11
|
-
import { createProps } from '../props'
|
|
12
16
|
import { throughInitialDefine, throughInitialExec } from '../iterate'
|
|
13
17
|
|
|
14
18
|
export const onlyResolveExtends = (element, parent, key, options) => {
|
|
@@ -24,10 +28,8 @@ export const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
24
28
|
|
|
25
29
|
// enable TRANSFORM in data
|
|
26
30
|
// TODO: do we need this at all?
|
|
27
|
-
// if (!element.transform) element.transform = {}
|
|
28
31
|
|
|
29
32
|
// enable CACHING
|
|
30
|
-
if (!ref.__cached) ref.__cached = {}
|
|
31
33
|
if (!ref.__defineCache) ref.__defineCache = {}
|
|
32
34
|
|
|
33
35
|
// enable EXEC
|
|
@@ -68,10 +70,11 @@ export const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
68
70
|
} else ref.__if = true
|
|
69
71
|
/// ///
|
|
70
72
|
|
|
71
|
-
if (element.node && ref.__if) {
|
|
73
|
+
if (element.node && ref.__if) {
|
|
74
|
+
parent[key || element.key] = element
|
|
75
|
+
} // Borrowed from assignNode()
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
applyVariant(element, parent)
|
|
77
|
+
initProps(element, parent, options)
|
|
75
78
|
|
|
76
79
|
if (element.tag !== 'string' && element.tag !== 'fragment') {
|
|
77
80
|
throughInitialDefine(element)
|
|
@@ -82,18 +85,26 @@ export const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
82
85
|
if (
|
|
83
86
|
isUndefined(prop) ||
|
|
84
87
|
isMethod(param, element) ||
|
|
85
|
-
isObject(REGISTRY[param])
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
isObject(REGISTRY[param])
|
|
89
|
+
) {
|
|
90
|
+
continue
|
|
91
|
+
}
|
|
88
92
|
|
|
89
93
|
const hasDefine = element.define && element.define[param]
|
|
90
|
-
const contextHasDefine =
|
|
91
|
-
|
|
94
|
+
const contextHasDefine =
|
|
95
|
+
element.context &&
|
|
96
|
+
element.context.define &&
|
|
97
|
+
element.context.define[param]
|
|
92
98
|
const optionsHasDefine = options.define && options.define[param]
|
|
93
99
|
|
|
94
100
|
if (REGISTRY[param] && !optionsHasDefine) {
|
|
95
101
|
continue
|
|
96
|
-
} else if (
|
|
102
|
+
} else if (
|
|
103
|
+
element[param] &&
|
|
104
|
+
!hasDefine &&
|
|
105
|
+
!optionsHasDefine &&
|
|
106
|
+
!contextHasDefine
|
|
107
|
+
) {
|
|
97
108
|
create(exec(prop, element), element, param, options)
|
|
98
109
|
}
|
|
99
110
|
}
|
|
@@ -104,7 +115,7 @@ export const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
104
115
|
delete element.update
|
|
105
116
|
delete element.__element
|
|
106
117
|
|
|
107
|
-
// added by
|
|
118
|
+
// added by initProps
|
|
108
119
|
if (element.props) {
|
|
109
120
|
delete element.props.update
|
|
110
121
|
delete element.props.__element
|
package/cache/index.js
DELETED
package/cache/options.js
DELETED
package/dist/cjs/cache/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var cache_exports = {};
|
|
20
|
-
__export(cache_exports, {
|
|
21
|
-
cache: () => cache
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(cache_exports);
|
|
24
|
-
const cache = {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var options_exports = {};
|
|
20
|
-
__export(options_exports, {
|
|
21
|
-
OPTIONS: () => OPTIONS,
|
|
22
|
-
default: () => options_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(options_exports);
|
|
25
|
-
const OPTIONS = {};
|
|
26
|
-
var options_default = OPTIONS;
|
package/dist/cjs/extend.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var extend_exports = {};
|
|
20
|
-
__export(extend_exports, {
|
|
21
|
-
applyExtend: () => applyExtend
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(extend_exports);
|
|
24
|
-
var import_utils = require("@domql/utils");
|
|
25
|
-
var import_utils2 = require("./utils/index.js");
|
|
26
|
-
const ENV = "development";
|
|
27
|
-
let mainExtend;
|
|
28
|
-
const applyExtend = (element, parent, options = {}) => {
|
|
29
|
-
if ((0, import_utils.isFunction)(element))
|
|
30
|
-
element = (0, import_utils.exec)(element, parent);
|
|
31
|
-
const { props, __ref } = element;
|
|
32
|
-
let extend = (props == null ? void 0 : props.extends) || element.extends || element.extend;
|
|
33
|
-
const variant = props == null ? void 0 : props.variant;
|
|
34
|
-
const context = element.context || parent.context;
|
|
35
|
-
extend = (0, import_utils2.fallbackStringExtend)(extend, context, options, variant);
|
|
36
|
-
const extendStack = (0, import_utils2.getExtendStack)(extend, context);
|
|
37
|
-
if (ENV !== "test" || ENV !== "development")
|
|
38
|
-
delete element.extend;
|
|
39
|
-
let childExtendStack = [];
|
|
40
|
-
if (parent) {
|
|
41
|
-
element.parent = parent;
|
|
42
|
-
if (!options.ignoreChildExtend && !(props && props.ignoreChildExtend)) {
|
|
43
|
-
childExtendStack = (0, import_utils2.getExtendStack)(parent.childExtend, context);
|
|
44
|
-
const ignoreChildExtendRecursive = props && props.ignoreChildExtendRecursive;
|
|
45
|
-
if (parent.childExtendRecursive && !ignoreChildExtendRecursive) {
|
|
46
|
-
const canExtendRecursive = element.key !== "__text";
|
|
47
|
-
if (canExtendRecursive) {
|
|
48
|
-
const childExtendRecursiveStack = (0, import_utils2.getExtendStack)(parent.childExtendRecursive, context);
|
|
49
|
-
childExtendStack = childExtendStack.concat(childExtendRecursiveStack);
|
|
50
|
-
element.childExtendRecursive = parent.childExtendRecursive;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const extendLength = extendStack.length;
|
|
56
|
-
const childExtendLength = childExtendStack.length;
|
|
57
|
-
let stack = [];
|
|
58
|
-
if (extendLength && childExtendLength) {
|
|
59
|
-
stack = (0, import_utils2.jointStacks)(extendStack, childExtendStack);
|
|
60
|
-
} else if (extendLength) {
|
|
61
|
-
stack = extendStack;
|
|
62
|
-
} else if (childExtendLength) {
|
|
63
|
-
stack = childExtendStack;
|
|
64
|
-
} else if (!context.defaultExtends)
|
|
65
|
-
return element;
|
|
66
|
-
if (context.defaultExtends) {
|
|
67
|
-
if (!mainExtend) {
|
|
68
|
-
const defaultOptionsExtend = (0, import_utils2.getExtendStack)(context.defaultExtends, context);
|
|
69
|
-
mainExtend = (0, import_utils2.cloneAndMergeArrayExtend)(defaultOptionsExtend);
|
|
70
|
-
delete mainExtend.extend;
|
|
71
|
-
}
|
|
72
|
-
stack = [].concat(stack, mainExtend);
|
|
73
|
-
}
|
|
74
|
-
if (__ref)
|
|
75
|
-
__ref.__extend = stack;
|
|
76
|
-
let mergedExtend = (0, import_utils2.cloneAndMergeArrayExtend)(stack);
|
|
77
|
-
const COMPONENTS = context && context.components || options.components;
|
|
78
|
-
const component = (0, import_utils.exec)(element.component || mergedExtend.component, element);
|
|
79
|
-
if (component && COMPONENTS && COMPONENTS[component]) {
|
|
80
|
-
const componentExtend = (0, import_utils2.cloneAndMergeArrayExtend)((0, import_utils2.getExtendStack)(COMPONENTS[component]));
|
|
81
|
-
mergedExtend = (0, import_utils2.deepMergeExtend)(componentExtend, mergedExtend);
|
|
82
|
-
}
|
|
83
|
-
const merged = (0, import_utils2.deepMergeExtend)(element, mergedExtend);
|
|
84
|
-
return merged;
|
|
85
|
-
};
|
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var methods_exports = {};
|
|
20
|
-
__export(methods_exports, {
|
|
21
|
-
METHODS: () => METHODS,
|
|
22
|
-
call: () => call,
|
|
23
|
-
defineSetter: () => defineSetter,
|
|
24
|
-
error: () => error,
|
|
25
|
-
get: () => get,
|
|
26
|
-
getPath: () => getPath,
|
|
27
|
-
getRef: () => getRef,
|
|
28
|
-
isMethod: () => isMethod,
|
|
29
|
-
keys: () => keys,
|
|
30
|
-
log: () => log,
|
|
31
|
-
lookdown: () => lookdown,
|
|
32
|
-
lookdownAll: () => lookdownAll,
|
|
33
|
-
lookup: () => lookup,
|
|
34
|
-
nextElement: () => nextElement,
|
|
35
|
-
parse: () => parse,
|
|
36
|
-
parseDeep: () => parseDeep,
|
|
37
|
-
previousElement: () => previousElement,
|
|
38
|
-
remove: () => remove,
|
|
39
|
-
setNodeStyles: () => setNodeStyles,
|
|
40
|
-
setProps: () => setProps,
|
|
41
|
-
spotByPath: () => spotByPath,
|
|
42
|
-
variables: () => variables,
|
|
43
|
-
verbose: () => verbose,
|
|
44
|
-
warn: () => warn
|
|
45
|
-
});
|
|
46
|
-
module.exports = __toCommonJS(methods_exports);
|
|
47
|
-
var import_event = require("@domql/event");
|
|
48
|
-
var import_utils = require("@domql/utils");
|
|
49
|
-
var import_tree = require("../tree.js");
|
|
50
|
-
var import_mixins = require("../mixins/index.js");
|
|
51
|
-
const ENV = "development";
|
|
52
|
-
function spotByPath(path) {
|
|
53
|
-
const element = this;
|
|
54
|
-
const arr = [].concat(path);
|
|
55
|
-
let active = import_tree.TREE[arr[0]];
|
|
56
|
-
if (!arr || !arr.length)
|
|
57
|
-
return console.log(arr, "on", element.key, "is undefined");
|
|
58
|
-
while (active.key === arr[0]) {
|
|
59
|
-
arr.shift();
|
|
60
|
-
if (!arr.length)
|
|
61
|
-
break;
|
|
62
|
-
active = active[arr[0]];
|
|
63
|
-
if (!active)
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
return active;
|
|
67
|
-
}
|
|
68
|
-
function lookup(param) {
|
|
69
|
-
const el = this;
|
|
70
|
-
let { parent } = el;
|
|
71
|
-
if ((0, import_utils.isFunction)(param)) {
|
|
72
|
-
if (parent.state && param(parent, parent.state, parent.context))
|
|
73
|
-
return parent;
|
|
74
|
-
else if (parent.parent)
|
|
75
|
-
return parent.lookup(param);
|
|
76
|
-
else
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (el[param])
|
|
80
|
-
return el[param];
|
|
81
|
-
while (parent.param !== param) {
|
|
82
|
-
if (parent[param])
|
|
83
|
-
return parent[param];
|
|
84
|
-
parent = parent.parent;
|
|
85
|
-
if (!parent)
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
return parent;
|
|
89
|
-
}
|
|
90
|
-
function lookdown(param) {
|
|
91
|
-
var _a;
|
|
92
|
-
const el = this;
|
|
93
|
-
const { __ref: ref } = el;
|
|
94
|
-
const children = ref.__children;
|
|
95
|
-
for (let i = 0; i < children.length; i++) {
|
|
96
|
-
const v = children[i];
|
|
97
|
-
const childElem = el[v];
|
|
98
|
-
if (v === param)
|
|
99
|
-
return childElem;
|
|
100
|
-
else if ((0, import_utils.isFunction)(param)) {
|
|
101
|
-
const exec = param(childElem, childElem.state, childElem.context);
|
|
102
|
-
if (childElem.state && exec) {
|
|
103
|
-
return childElem;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
const lookdown2 = (_a = childElem == null ? void 0 : childElem.lookdown) == null ? void 0 : _a.call(childElem, param);
|
|
107
|
-
if (lookdown2)
|
|
108
|
-
return lookdown2;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function lookdownAll(param, results = []) {
|
|
112
|
-
var _a;
|
|
113
|
-
const el = this;
|
|
114
|
-
const { __ref: ref } = el;
|
|
115
|
-
const children = ref.__children;
|
|
116
|
-
for (let i = 0; i < children.length; i++) {
|
|
117
|
-
const v = children[i];
|
|
118
|
-
const childElem = el[v];
|
|
119
|
-
if (v === param)
|
|
120
|
-
results.push(childElem);
|
|
121
|
-
else if ((0, import_utils.isFunction)(param)) {
|
|
122
|
-
const exec = param(childElem, childElem.state, childElem.context);
|
|
123
|
-
if (childElem.state && exec)
|
|
124
|
-
results.push(childElem);
|
|
125
|
-
}
|
|
126
|
-
(_a = childElem == null ? void 0 : childElem.lookdownAll) == null ? void 0 : _a.call(childElem, param, results);
|
|
127
|
-
}
|
|
128
|
-
return results.length ? results : void 0;
|
|
129
|
-
}
|
|
130
|
-
function setNodeStyles(params = {}) {
|
|
131
|
-
var _a;
|
|
132
|
-
const el = this;
|
|
133
|
-
if (!((_a = el.node) == null ? void 0 : _a.style))
|
|
134
|
-
return;
|
|
135
|
-
for (const param in params) {
|
|
136
|
-
const value = params[param];
|
|
137
|
-
const childElem = el[param];
|
|
138
|
-
if ((0, import_utils.isObject)(value) && childElem)
|
|
139
|
-
setNodeStyles.call(childElem, value);
|
|
140
|
-
else
|
|
141
|
-
el.node.style[param] = value;
|
|
142
|
-
}
|
|
143
|
-
return el;
|
|
144
|
-
}
|
|
145
|
-
function remove(opts) {
|
|
146
|
-
const element = this;
|
|
147
|
-
const beforeRemoveReturns = (0, import_event.triggerEventOn)("beforeRemove", element, opts);
|
|
148
|
-
if (beforeRemoveReturns === false)
|
|
149
|
-
return element;
|
|
150
|
-
if ((0, import_utils.isFunction)(element.node.remove))
|
|
151
|
-
element.node.remove();
|
|
152
|
-
else if (!(0, import_utils.isProduction)()) {
|
|
153
|
-
console.warn("This item cant be removed");
|
|
154
|
-
element.log();
|
|
155
|
-
}
|
|
156
|
-
delete element.parent[element.key];
|
|
157
|
-
if (element.parent.__ref)
|
|
158
|
-
element.parent.__ref.__children = (0, import_utils.removeValueFromArray)(element.parent.__ref.__children, element.key);
|
|
159
|
-
(0, import_event.triggerEventOn)("remove", element, opts);
|
|
160
|
-
}
|
|
161
|
-
function get(param) {
|
|
162
|
-
const element = this;
|
|
163
|
-
return element[param];
|
|
164
|
-
}
|
|
165
|
-
function setProps(param, options) {
|
|
166
|
-
const element = this;
|
|
167
|
-
if (!param || !element.props)
|
|
168
|
-
return;
|
|
169
|
-
element.update({ props: param }, options);
|
|
170
|
-
return element;
|
|
171
|
-
}
|
|
172
|
-
function getRef() {
|
|
173
|
-
return this.__ref;
|
|
174
|
-
}
|
|
175
|
-
function getPath() {
|
|
176
|
-
return this.getRef().path;
|
|
177
|
-
}
|
|
178
|
-
const defineSetter = (element, key, get2, set) => Object.defineProperty(element, key, { get: get2, set });
|
|
179
|
-
function keys() {
|
|
180
|
-
const element = this;
|
|
181
|
-
const keys2 = [];
|
|
182
|
-
for (const param in element) {
|
|
183
|
-
if (import_mixins.REGISTRY[param] && !import_mixins.parseFilters.elementKeys.includes(param) || !Object.hasOwnProperty.call(element, param)) {
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
keys2.push(param);
|
|
187
|
-
}
|
|
188
|
-
return keys2;
|
|
189
|
-
}
|
|
190
|
-
function parse(excl = []) {
|
|
191
|
-
const element = this;
|
|
192
|
-
const obj = {};
|
|
193
|
-
const keyList = keys.call(element);
|
|
194
|
-
keyList.forEach((v) => {
|
|
195
|
-
if (excl.includes(v))
|
|
196
|
-
return;
|
|
197
|
-
const val = element[v];
|
|
198
|
-
if (v === "state") {
|
|
199
|
-
if (element.__ref && !element.__ref.__hasRootState)
|
|
200
|
-
return;
|
|
201
|
-
const parsedVal = (0, import_utils.isFunction)(val && val.parse) ? val.parse() : val;
|
|
202
|
-
obj[v] = (0, import_utils.isFunction)(parsedVal) ? parsedVal : JSON.parse(JSON.stringify(parsedVal || {}));
|
|
203
|
-
} else if (v === "scope") {
|
|
204
|
-
if (element.__ref && !element.__ref.__hasRootScope)
|
|
205
|
-
return;
|
|
206
|
-
obj[v] = JSON.parse(JSON.stringify(val || {}));
|
|
207
|
-
} else if (v === "props") {
|
|
208
|
-
const { __element, update, ...props } = element[v];
|
|
209
|
-
obj[v] = props;
|
|
210
|
-
} else if ((0, import_utils.isDefined)(val) && Object.hasOwnProperty.call(element, v))
|
|
211
|
-
obj[v] = val;
|
|
212
|
-
});
|
|
213
|
-
return obj;
|
|
214
|
-
}
|
|
215
|
-
function parseDeep(excl = []) {
|
|
216
|
-
const element = this;
|
|
217
|
-
const obj = parse.call(element, excl);
|
|
218
|
-
for (const v in obj) {
|
|
219
|
-
if (excl.includes(v))
|
|
220
|
-
return;
|
|
221
|
-
if ((0, import_utils.isObjectLike)(obj[v])) {
|
|
222
|
-
obj[v] = parseDeep.call(obj[v], excl);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
return obj;
|
|
226
|
-
}
|
|
227
|
-
function verbose(...args) {
|
|
228
|
-
if (ENV !== "test" && ENV !== "development")
|
|
229
|
-
return;
|
|
230
|
-
const element = this;
|
|
231
|
-
const { __ref: ref } = element;
|
|
232
|
-
console.groupCollapsed(element.key);
|
|
233
|
-
if (args.length) {
|
|
234
|
-
args.forEach((v) => console.log(`%c${v}:
|
|
235
|
-
`, "font-weight: bold", element[v]));
|
|
236
|
-
} else {
|
|
237
|
-
console.log(ref.path);
|
|
238
|
-
const keys2 = element.keys();
|
|
239
|
-
keys2.forEach((v) => console.log(`%c${v}:`, "font-weight: bold", element[v]));
|
|
240
|
-
}
|
|
241
|
-
console.log(element);
|
|
242
|
-
console.groupEnd(element.key);
|
|
243
|
-
return element;
|
|
244
|
-
}
|
|
245
|
-
function log(...params) {
|
|
246
|
-
if (ENV === "test" || ENV === "development") {
|
|
247
|
-
console.log(...params);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
function warn(...params) {
|
|
251
|
-
if (ENV === "test" || ENV === "development") {
|
|
252
|
-
console.warn(...params);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function error(...params) {
|
|
256
|
-
var _a, _b;
|
|
257
|
-
if (ENV === "test" || ENV === "development") {
|
|
258
|
-
if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger)
|
|
259
|
-
debugger;
|
|
260
|
-
if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose)
|
|
261
|
-
verbose.call(this);
|
|
262
|
-
throw new Error(...params);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
function nextElement() {
|
|
266
|
-
const element = this;
|
|
267
|
-
const { key, parent } = element;
|
|
268
|
-
const { __children } = parent.__ref;
|
|
269
|
-
const currentIndex = __children.indexOf(key);
|
|
270
|
-
const nextChild = __children[currentIndex + 1];
|
|
271
|
-
return parent[nextChild];
|
|
272
|
-
}
|
|
273
|
-
function previousElement(el) {
|
|
274
|
-
const element = el || this;
|
|
275
|
-
const { key, parent } = element;
|
|
276
|
-
const { __children } = parent.__ref;
|
|
277
|
-
if (!__children)
|
|
278
|
-
return;
|
|
279
|
-
const currentIndex = __children.indexOf(key);
|
|
280
|
-
return parent[__children[currentIndex - 1]];
|
|
281
|
-
}
|
|
282
|
-
function variables(obj = {}) {
|
|
283
|
-
const element = this;
|
|
284
|
-
if (!element.data)
|
|
285
|
-
element.data = {};
|
|
286
|
-
if (!element.data.varCaches)
|
|
287
|
-
element.data.varCaches = {};
|
|
288
|
-
const varCaches = element.data.varCaches;
|
|
289
|
-
const changes = {};
|
|
290
|
-
let changed;
|
|
291
|
-
for (const key in obj) {
|
|
292
|
-
if (obj[key] !== varCaches[key]) {
|
|
293
|
-
changed = true;
|
|
294
|
-
changes[key] = obj[key];
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return {
|
|
298
|
-
changed: (cb) => {
|
|
299
|
-
if (!changed)
|
|
300
|
-
return;
|
|
301
|
-
const returns = cb(changes, (0, import_utils.deepClone)(varCaches));
|
|
302
|
-
for (const key in changes) {
|
|
303
|
-
varCaches[key] = changes[key];
|
|
304
|
-
}
|
|
305
|
-
return returns;
|
|
306
|
-
},
|
|
307
|
-
timeout: (cb, timeout) => {
|
|
308
|
-
if (!changed)
|
|
309
|
-
return;
|
|
310
|
-
const t = setTimeout(() => {
|
|
311
|
-
cb(changes);
|
|
312
|
-
clearTimeout(t);
|
|
313
|
-
}, timeout);
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
function call(fnKey, ...args) {
|
|
318
|
-
var _a;
|
|
319
|
-
const context = this.context;
|
|
320
|
-
return (_a = context.utils[fnKey] || context.functions[fnKey] || context.methods[fnKey] || context.snippets[fnKey]) == null ? void 0 : _a.call(this, ...args);
|
|
321
|
-
}
|
|
322
|
-
const METHODS = [
|
|
323
|
-
"set",
|
|
324
|
-
"reset",
|
|
325
|
-
"update",
|
|
326
|
-
"remove",
|
|
327
|
-
"updateContent",
|
|
328
|
-
"removeContent",
|
|
329
|
-
"lookup",
|
|
330
|
-
"lookdown",
|
|
331
|
-
"lookdownAll",
|
|
332
|
-
"getRef",
|
|
333
|
-
"getPath",
|
|
334
|
-
"setNodeStyles",
|
|
335
|
-
"spotByPath",
|
|
336
|
-
"keys",
|
|
337
|
-
"parse",
|
|
338
|
-
"setProps",
|
|
339
|
-
"parseDeep",
|
|
340
|
-
"variables",
|
|
341
|
-
"if",
|
|
342
|
-
"log",
|
|
343
|
-
"verbose",
|
|
344
|
-
"warn",
|
|
345
|
-
"error",
|
|
346
|
-
"call",
|
|
347
|
-
"nextElement",
|
|
348
|
-
"previousElement"
|
|
349
|
-
];
|
|
350
|
-
function isMethod(param, element) {
|
|
351
|
-
var _a, _b;
|
|
352
|
-
return METHODS.includes(param) || ((_b = (_a = element == null ? void 0 : element.context) == null ? void 0 : _a.methods) == null ? void 0 : _b[param]);
|
|
353
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var content_exports = {};
|
|
20
|
-
__export(content_exports, {
|
|
21
|
-
default: () => content_default,
|
|
22
|
-
removeContent: () => removeContent,
|
|
23
|
-
setContent: () => setContent,
|
|
24
|
-
updateContent: () => updateContent
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(content_exports);
|
|
27
|
-
var import_utils = require("@domql/utils");
|
|
28
|
-
var import_set = require("../set.js");
|
|
29
|
-
const updateContent = function(params, options) {
|
|
30
|
-
const element = this;
|
|
31
|
-
const ref = element.__ref;
|
|
32
|
-
const contentKey = ref.contentElementKey;
|
|
33
|
-
if (!element[contentKey])
|
|
34
|
-
return;
|
|
35
|
-
if (element[contentKey].update)
|
|
36
|
-
element[contentKey].update(params, options);
|
|
37
|
-
};
|
|
38
|
-
const removeContent = function(el, opts = {}) {
|
|
39
|
-
const element = el || this;
|
|
40
|
-
const { __ref: ref } = element;
|
|
41
|
-
const contentElementKey = (0, import_utils.setContentKey)(element, opts);
|
|
42
|
-
if (opts.contentElementKey !== "content")
|
|
43
|
-
opts.contentElementKey = "content";
|
|
44
|
-
if (element[contentElementKey]) {
|
|
45
|
-
if (element[contentElementKey].node && element.node) {
|
|
46
|
-
if (element[contentElementKey].tag === "fragment")
|
|
47
|
-
element.node.innerHTML = "";
|
|
48
|
-
else {
|
|
49
|
-
const contentNode = element[contentElementKey].node;
|
|
50
|
-
if (contentNode.parentNode === element.node)
|
|
51
|
-
element.node.removeChild(element[contentElementKey].node);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const { __cached } = ref;
|
|
55
|
-
if (__cached && __cached[contentElementKey]) {
|
|
56
|
-
if (__cached[contentElementKey].tag === "fragment")
|
|
57
|
-
__cached[contentElementKey].parent.node.innerHTML = "";
|
|
58
|
-
else if (__cached[contentElementKey] && (0, import_utils.isFunction)(__cached[contentElementKey].remove))
|
|
59
|
-
__cached[contentElementKey].remove();
|
|
60
|
-
}
|
|
61
|
-
delete element[contentElementKey];
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
function setContent(param, element, node, opts) {
|
|
65
|
-
const contentElementKey = (0, import_utils.setContentKey)(element, opts);
|
|
66
|
-
if (param && element) {
|
|
67
|
-
if (element[contentElementKey].update) {
|
|
68
|
-
element[contentElementKey].update({}, opts);
|
|
69
|
-
} else {
|
|
70
|
-
import_set.set.call(element, param, opts);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
var content_default = setContent;
|