@domql/element 2.5.96 → 2.5.99
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/create.js +5 -5
- package/dist/cjs/create.js +5 -7
- package/dist/cjs/methods/index.js +23 -0
- package/dist/cjs/methods/set.js +1 -0
- package/dist/cjs/mixins/registry.js +1 -0
- package/dist/cjs/utils/component.js +3 -1
- package/methods/index.js +24 -0
- package/methods/set.js +2 -0
- package/mixins/registry.js +1 -0
- package/package.json +2 -2
- package/utils/component.js +4 -1
package/create.js
CHANGED
|
@@ -309,11 +309,11 @@ const addCaching = (element, parent) => {
|
|
|
309
309
|
if (!ref.root) ref.root = hasRoot ? element : parentRef.root
|
|
310
310
|
|
|
311
311
|
// set the PATH array
|
|
312
|
-
if (ENV === 'test' || ENV === 'development') {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
312
|
+
// if (ENV === 'test' || ENV === 'development') {
|
|
313
|
+
if (!parentRef) parentRef = parent.ref = {}
|
|
314
|
+
if (!parentRef.__path) parentRef.__path = []
|
|
315
|
+
ref.__path = parentRef.__path.concat(element.key)
|
|
316
|
+
// }
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
const onlyResolveExtends = (element, parent, key, options) => {
|
package/dist/cjs/create.js
CHANGED
|
@@ -239,13 +239,11 @@ const addCaching = (element, parent) => {
|
|
|
239
239
|
const hasRoot = parent && parent.key === ":root";
|
|
240
240
|
if (!ref.root)
|
|
241
241
|
ref.root = hasRoot ? element : parentRef.root;
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
ref.__path = parentRef.__path.concat(element.key);
|
|
248
|
-
}
|
|
242
|
+
if (!parentRef)
|
|
243
|
+
parentRef = parent.ref = {};
|
|
244
|
+
if (!parentRef.__path)
|
|
245
|
+
parentRef.__path = [];
|
|
246
|
+
ref.__path = parentRef.__path.concat(element.key);
|
|
249
247
|
};
|
|
250
248
|
const onlyResolveExtends = (element, parent, key, options) => {
|
|
251
249
|
const { __ref: ref } = element;
|
|
@@ -24,6 +24,7 @@ __export(methods_exports, {
|
|
|
24
24
|
isMethod: () => isMethod,
|
|
25
25
|
keys: () => keys,
|
|
26
26
|
log: () => log,
|
|
27
|
+
lookdown: () => lookdown,
|
|
27
28
|
lookup: () => lookup,
|
|
28
29
|
nextElement: () => nextElement,
|
|
29
30
|
parse: () => parse,
|
|
@@ -73,6 +74,27 @@ const lookup = function(param) {
|
|
|
73
74
|
}
|
|
74
75
|
return parent;
|
|
75
76
|
};
|
|
77
|
+
const lookdown = function(param) {
|
|
78
|
+
const el = this;
|
|
79
|
+
const { __ref: ref } = el;
|
|
80
|
+
const children = ref.__children;
|
|
81
|
+
for (let i = 0; i < children.length; i++) {
|
|
82
|
+
const v = children[i];
|
|
83
|
+
const childElem = el[v];
|
|
84
|
+
if (v === param)
|
|
85
|
+
return childElem;
|
|
86
|
+
else if ((0, import_utils.isFunction)(param)) {
|
|
87
|
+
const exec = param(childElem, childElem.state, childElem.context);
|
|
88
|
+
if (childElem.state && exec) {
|
|
89
|
+
return childElem;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const lookdown2 = childElem.lookdown(param);
|
|
93
|
+
if (lookdown2)
|
|
94
|
+
return lookdown2;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
76
98
|
const remove = function() {
|
|
77
99
|
const element = this;
|
|
78
100
|
if ((0, import_utils.isFunction)(element.node.remove))
|
|
@@ -183,6 +205,7 @@ const METHODS = [
|
|
|
183
205
|
"updateContent",
|
|
184
206
|
"removeContent",
|
|
185
207
|
"lookup",
|
|
208
|
+
"lookdown",
|
|
186
209
|
"spotByPath",
|
|
187
210
|
"keys",
|
|
188
211
|
"parse",
|
package/dist/cjs/methods/set.js
CHANGED
|
@@ -45,6 +45,7 @@ const addMethods = (element, parent) => {
|
|
|
45
45
|
removeContent: import_content.removeContent.bind(element),
|
|
46
46
|
setProps: import__.setProps.bind(element),
|
|
47
47
|
lookup: import__.lookup.bind(element),
|
|
48
|
+
lookdown: import__.lookdown.bind(element),
|
|
48
49
|
spotByPath: import__.spotByPath.bind(element),
|
|
49
50
|
parse: import__.parse.bind(element),
|
|
50
51
|
parseDeep: import__.parseDeep.bind(element),
|
|
@@ -168,7 +168,9 @@ const overwriteVariant = (element, variant, variantProps) => {
|
|
|
168
168
|
} else if (variantElement.extend) {
|
|
169
169
|
variantElement = addAdditionalExtend({ props }, variantElement);
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
const extendedVariant = (0, import_extend.applyExtend)(variantElement, element.parent);
|
|
172
|
+
const { parent, ...rest } = extendedVariant;
|
|
173
|
+
return (0, import_utils.overwriteDeep)(element, rest);
|
|
172
174
|
};
|
|
173
175
|
const applyVariant = (element) => {
|
|
174
176
|
const { props } = element;
|
package/methods/index.js
CHANGED
|
@@ -42,6 +42,29 @@ export const lookup = function (param) {
|
|
|
42
42
|
return parent
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
export const lookdown = function (param) {
|
|
46
|
+
const el = this
|
|
47
|
+
const { __ref: ref } = el
|
|
48
|
+
const children = ref.__children
|
|
49
|
+
|
|
50
|
+
for (let i = 0; i < children.length; i++) {
|
|
51
|
+
const v = children[i]
|
|
52
|
+
const childElem = el[v]
|
|
53
|
+
|
|
54
|
+
if (v === param) return childElem
|
|
55
|
+
else if (isFunction(param)) {
|
|
56
|
+
const exec = param(childElem, childElem.state, childElem.context)
|
|
57
|
+
if (childElem.state && exec) {
|
|
58
|
+
return childElem
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const lookdown = childElem.lookdown(param)
|
|
62
|
+
if (lookdown) return lookdown
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return null
|
|
66
|
+
}
|
|
67
|
+
|
|
45
68
|
export const remove = function () {
|
|
46
69
|
const element = this
|
|
47
70
|
if (isFunction(element.node.remove)) element.node.remove()
|
|
@@ -159,6 +182,7 @@ export const METHODS = [
|
|
|
159
182
|
'updateContent',
|
|
160
183
|
'removeContent',
|
|
161
184
|
'lookup',
|
|
185
|
+
'lookdown',
|
|
162
186
|
'spotByPath',
|
|
163
187
|
'keys',
|
|
164
188
|
'parse',
|
package/methods/set.js
CHANGED
|
@@ -7,6 +7,7 @@ import update from '../update'
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
lookup,
|
|
10
|
+
lookdown,
|
|
10
11
|
setProps,
|
|
11
12
|
remove,
|
|
12
13
|
spotByPath,
|
|
@@ -29,6 +30,7 @@ export const addMethods = (element, parent) => {
|
|
|
29
30
|
removeContent: removeContent.bind(element),
|
|
30
31
|
setProps: setProps.bind(element),
|
|
31
32
|
lookup: lookup.bind(element),
|
|
33
|
+
lookdown: lookdown.bind(element),
|
|
32
34
|
spotByPath: spotByPath.bind(element),
|
|
33
35
|
parse: parse.bind(element),
|
|
34
36
|
parseDeep: parseDeep.bind(element),
|
package/mixins/registry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.99",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@domql/state": "latest",
|
|
32
32
|
"@domql/utils": "latest"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "831c32c658ca5d64665f59f10520ce2a3408d76f",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|
package/utils/component.js
CHANGED
|
@@ -155,7 +155,10 @@ export const overwriteVariant = (element, variant, variantProps) => {
|
|
|
155
155
|
} else if (variantElement.extend) {
|
|
156
156
|
variantElement = addAdditionalExtend({ props }, variantElement)
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
const extendedVariant = applyExtend(variantElement, element.parent)
|
|
159
|
+
const { parent, ...rest } = extendedVariant
|
|
160
|
+
return overwriteDeep(element, rest) // TODO: check why string is not working
|
|
161
|
+
// return overwriteDeep(element, applyExtend(variantElement, element.parent)) // TODO: check why string is not working
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
export const applyVariant = (element) => {
|