@domql/element 2.5.100 → 2.5.102
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/methods/index.js +20 -0
- package/dist/cjs/methods/set.js +1 -0
- package/dist/cjs/mixins/attr.js +1 -1
- package/dist/cjs/mixins/registry.js +1 -0
- package/methods/index.js +21 -0
- package/methods/set.js +2 -0
- package/mixins/attr.js +2 -2
- package/mixins/registry.js +1 -0
- package/package.json +2 -2
|
@@ -25,6 +25,7 @@ __export(methods_exports, {
|
|
|
25
25
|
keys: () => keys,
|
|
26
26
|
log: () => log,
|
|
27
27
|
lookdown: () => lookdown,
|
|
28
|
+
lookdownAll: () => lookdownAll,
|
|
28
29
|
lookup: () => lookup,
|
|
29
30
|
nextElement: () => nextElement,
|
|
30
31
|
parse: () => parse,
|
|
@@ -95,6 +96,24 @@ const lookdown = function(param) {
|
|
|
95
96
|
}
|
|
96
97
|
return null;
|
|
97
98
|
};
|
|
99
|
+
const lookdownAll = function(param, results = []) {
|
|
100
|
+
const el = this;
|
|
101
|
+
const { __ref: ref } = el;
|
|
102
|
+
const children = ref.__children;
|
|
103
|
+
for (let i = 0; i < children.length; i++) {
|
|
104
|
+
const v = children[i];
|
|
105
|
+
const childElem = el[v];
|
|
106
|
+
if (v === param)
|
|
107
|
+
results.push(childElem);
|
|
108
|
+
else if ((0, import_utils.isFunction)(param)) {
|
|
109
|
+
const exec = param(childElem, childElem.state, childElem.context);
|
|
110
|
+
if (childElem.state && exec)
|
|
111
|
+
results.push(childElem);
|
|
112
|
+
}
|
|
113
|
+
childElem == null ? void 0 : childElem.lookdownAll(param, results);
|
|
114
|
+
}
|
|
115
|
+
return results.length ? results : null;
|
|
116
|
+
};
|
|
98
117
|
const remove = function() {
|
|
99
118
|
const element = this;
|
|
100
119
|
if ((0, import_utils.isFunction)(element.node.remove))
|
|
@@ -206,6 +225,7 @@ const METHODS = [
|
|
|
206
225
|
"removeContent",
|
|
207
226
|
"lookup",
|
|
208
227
|
"lookdown",
|
|
228
|
+
"lookdownAll",
|
|
209
229
|
"spotByPath",
|
|
210
230
|
"keys",
|
|
211
231
|
"parse",
|
package/dist/cjs/methods/set.js
CHANGED
|
@@ -46,6 +46,7 @@ const addMethods = (element, parent) => {
|
|
|
46
46
|
setProps: import__.setProps.bind(element),
|
|
47
47
|
lookup: import__.lookup.bind(element),
|
|
48
48
|
lookdown: import__.lookdown.bind(element),
|
|
49
|
+
lookdownAll: import__.lookdownAll.bind(element),
|
|
49
50
|
spotByPath: import__.spotByPath.bind(element),
|
|
50
51
|
parse: import__.parse.bind(element),
|
|
51
52
|
parseDeep: import__.parseDeep.bind(element),
|
package/dist/cjs/mixins/attr.js
CHANGED
|
@@ -31,7 +31,7 @@ var attr_default = (params, element, node) => {
|
|
|
31
31
|
if (params) {
|
|
32
32
|
for (const attr in params) {
|
|
33
33
|
const val = (0, import_utils.exec)(params[attr], element);
|
|
34
|
-
if (val && node.setAttribute)
|
|
34
|
+
if ((0, import_utils.isDefined)(val) && node.setAttribute)
|
|
35
35
|
node.setAttribute(attr, val);
|
|
36
36
|
else if (node.removeAttribute)
|
|
37
37
|
node.removeAttribute(attr);
|
package/methods/index.js
CHANGED
|
@@ -65,6 +65,26 @@ export const lookdown = function (param) {
|
|
|
65
65
|
return null
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
export const lookdownAll = function (param, results = []) {
|
|
69
|
+
const el = this
|
|
70
|
+
const { __ref: ref } = el
|
|
71
|
+
const children = ref.__children
|
|
72
|
+
|
|
73
|
+
for (let i = 0; i < children.length; i++) {
|
|
74
|
+
const v = children[i]
|
|
75
|
+
const childElem = el[v]
|
|
76
|
+
|
|
77
|
+
if (v === param) results.push(childElem)
|
|
78
|
+
else if (isFunction(param)) {
|
|
79
|
+
const exec = param(childElem, childElem.state, childElem.context)
|
|
80
|
+
if (childElem.state && exec) results.push(childElem)
|
|
81
|
+
}
|
|
82
|
+
childElem?.lookdownAll(param, results)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return results.length ? results : null
|
|
86
|
+
}
|
|
87
|
+
|
|
68
88
|
export const remove = function () {
|
|
69
89
|
const element = this
|
|
70
90
|
if (isFunction(element.node.remove)) element.node.remove()
|
|
@@ -183,6 +203,7 @@ export const METHODS = [
|
|
|
183
203
|
'removeContent',
|
|
184
204
|
'lookup',
|
|
185
205
|
'lookdown',
|
|
206
|
+
'lookdownAll',
|
|
186
207
|
'spotByPath',
|
|
187
208
|
'keys',
|
|
188
209
|
'parse',
|
package/methods/set.js
CHANGED
|
@@ -8,6 +8,7 @@ import update from '../update'
|
|
|
8
8
|
import {
|
|
9
9
|
lookup,
|
|
10
10
|
lookdown,
|
|
11
|
+
lookdownAll,
|
|
11
12
|
setProps,
|
|
12
13
|
remove,
|
|
13
14
|
spotByPath,
|
|
@@ -31,6 +32,7 @@ export const addMethods = (element, parent) => {
|
|
|
31
32
|
setProps: setProps.bind(element),
|
|
32
33
|
lookup: lookup.bind(element),
|
|
33
34
|
lookdown: lookdown.bind(element),
|
|
35
|
+
lookdownAll: lookdownAll.bind(element),
|
|
34
36
|
spotByPath: spotByPath.bind(element),
|
|
35
37
|
parse: parse.bind(element),
|
|
36
38
|
parseDeep: parseDeep.bind(element),
|
package/mixins/attr.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { exec, isNot } from '@domql/utils'
|
|
3
|
+
import { exec, isNot, isDefined } from '@domql/utils'
|
|
4
4
|
import { report } from '@domql/report'
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -14,7 +14,7 @@ export default (params, element, node) => {
|
|
|
14
14
|
for (const attr in params) {
|
|
15
15
|
const val = exec(params[attr], element)
|
|
16
16
|
// if (__attr[attr] === val) return
|
|
17
|
-
if (val && node.setAttribute) node.setAttribute(attr, val)
|
|
17
|
+
if (isDefined(val) && node.setAttribute) node.setAttribute(attr, val)
|
|
18
18
|
else if (node.removeAttribute) node.removeAttribute(attr)
|
|
19
19
|
__attr[attr] = val
|
|
20
20
|
}
|
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.102",
|
|
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": "9f0516bbf6310b86c6d78f6bb0bfd3bf3347469b",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|