@domql/element 2.5.148 → 2.5.150
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 +3 -3
- package/dist/cjs/create.js +3 -3
- package/dist/cjs/methods/index.js +8 -4
- package/dist/cjs/methods/set.js +5 -7
- package/dist/cjs/mixins/data.js +2 -2
- package/dist/cjs/props/create.js +11 -6
- package/dist/cjs/utils/onlyResolveExtends.js +1 -1
- package/methods/index.js +6 -3
- package/methods/set.js +6 -8
- package/mixins/data.js +1 -1
- package/package.json +6 -6
- package/props/create.js +9 -6
- package/utils/onlyResolveExtends.js +1 -1
package/create.js
CHANGED
|
@@ -90,7 +90,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}, attachOpti
|
|
|
90
90
|
createIfConditionFlag(element, parent)
|
|
91
91
|
|
|
92
92
|
// apply props settings
|
|
93
|
-
createProps(element, parent)
|
|
93
|
+
createProps(element, parent, options)
|
|
94
94
|
if (element.scope === 'props' || element.scope === true) element.scope = element.props
|
|
95
95
|
|
|
96
96
|
// recatch if it passess props again
|
|
@@ -234,7 +234,7 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
234
234
|
const isDemoComponent = element.lookup(el => el.state.key)?.state?.key
|
|
235
235
|
element.warn('Error happened in:', isDemoComponent ? isDemoComponent + ' ' : '' + path.join('.'))
|
|
236
236
|
element.verbose()
|
|
237
|
-
element.error(e)
|
|
237
|
+
element.error(e, options)
|
|
238
238
|
if (element.on?.error) element.on.error(e, element, element.state, element.context, options)
|
|
239
239
|
if (element.props?.onError) element.props.onError(e, element, element.state, element.context, options)
|
|
240
240
|
}
|
|
@@ -354,7 +354,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
354
354
|
createIfConditionFlag(element, parent)
|
|
355
355
|
|
|
356
356
|
// apply props settings
|
|
357
|
-
createProps(element, parent)
|
|
357
|
+
createProps(element, parent, options)
|
|
358
358
|
if (element.scope === 'props' || element.scope === true) element.scope = element.props
|
|
359
359
|
|
|
360
360
|
if (element.node && ref.__if) { parent[key || element.key] = element } // Borrowed from assignNode()
|
package/dist/cjs/create.js
CHANGED
|
@@ -74,7 +74,7 @@ const create = (element, parent, key, options = import_options.default.create ||
|
|
|
74
74
|
if (element.scope === "state")
|
|
75
75
|
element.scope = element.state;
|
|
76
76
|
createIfConditionFlag(element, parent);
|
|
77
|
-
(0, import_props.createProps)(element, parent);
|
|
77
|
+
(0, import_props.createProps)(element, parent, options);
|
|
78
78
|
if (element.scope === "props" || element.scope === true)
|
|
79
79
|
element.scope = element.props;
|
|
80
80
|
createIfConditionFlag(element, parent);
|
|
@@ -192,7 +192,7 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
192
192
|
const isDemoComponent = (_b = (_a = element.lookup((el) => el.state.key)) == null ? void 0 : _a.state) == null ? void 0 : _b.key;
|
|
193
193
|
element.warn("Error happened in:", isDemoComponent ? isDemoComponent + " " : "" + path.join("."));
|
|
194
194
|
element.verbose();
|
|
195
|
-
element.error(e);
|
|
195
|
+
element.error(e, options);
|
|
196
196
|
if ((_c = element.on) == null ? void 0 : _c.error)
|
|
197
197
|
element.on.error(e, element, element.state, element.context, options);
|
|
198
198
|
if ((_d = element.props) == null ? void 0 : _d.onError)
|
|
@@ -283,7 +283,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
283
283
|
if (element.scope === "state")
|
|
284
284
|
element.scope = element.state;
|
|
285
285
|
createIfConditionFlag(element, parent);
|
|
286
|
-
(0, import_props.createProps)(element, parent);
|
|
286
|
+
(0, import_props.createProps)(element, parent, options);
|
|
287
287
|
if (element.scope === "props" || element.scope === true)
|
|
288
288
|
element.scope = element.props;
|
|
289
289
|
if (element.node && ref.__if) {
|
|
@@ -166,7 +166,7 @@ function keys() {
|
|
|
166
166
|
const element = this;
|
|
167
167
|
const keys2 = [];
|
|
168
168
|
for (const param in element) {
|
|
169
|
-
if (import_mixins.registry[param] && !import_mixins.parseFilters.elementKeys.includes(param)) {
|
|
169
|
+
if (import_mixins.registry[param] && !import_mixins.parseFilters.elementKeys.includes(param) || Object.hasOwnProperty.call(element, param)) {
|
|
170
170
|
continue;
|
|
171
171
|
}
|
|
172
172
|
keys2.push(param);
|
|
@@ -178,7 +178,6 @@ function parse(excl = []) {
|
|
|
178
178
|
const obj = {};
|
|
179
179
|
const keyList = keys.call(element);
|
|
180
180
|
keyList.forEach((v) => {
|
|
181
|
-
var _a;
|
|
182
181
|
if (excl.includes(v))
|
|
183
182
|
return;
|
|
184
183
|
const val = element[v];
|
|
@@ -194,7 +193,7 @@ function parse(excl = []) {
|
|
|
194
193
|
} else if (v === "props") {
|
|
195
194
|
const { __element, update, ...props } = element[v];
|
|
196
195
|
obj[v] = props;
|
|
197
|
-
} else if ((0, import_utils.isDefined)(val) &&
|
|
196
|
+
} else if ((0, import_utils.isDefined)(val) && Object.hasOwnProperty.call(element, v))
|
|
198
197
|
obj[v] = val;
|
|
199
198
|
});
|
|
200
199
|
return obj;
|
|
@@ -212,9 +211,11 @@ function parseDeep(excl = []) {
|
|
|
212
211
|
return obj;
|
|
213
212
|
}
|
|
214
213
|
function verbose(...args) {
|
|
214
|
+
if (ENV !== "test" && ENV !== "development")
|
|
215
|
+
return;
|
|
215
216
|
const element = this;
|
|
216
217
|
const { __ref: ref } = element;
|
|
217
|
-
console.
|
|
218
|
+
console.groupCollapsed(element.key);
|
|
218
219
|
if (args.length) {
|
|
219
220
|
args.forEach((v) => console.log(`%c${v}:
|
|
220
221
|
`, "font-weight: bold", element[v]));
|
|
@@ -238,7 +239,10 @@ function warn(...params) {
|
|
|
238
239
|
}
|
|
239
240
|
}
|
|
240
241
|
function error(...params) {
|
|
242
|
+
var _a;
|
|
241
243
|
if (ENV === "test" || ENV === "development") {
|
|
244
|
+
if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger)
|
|
245
|
+
debugger;
|
|
242
246
|
console.error(...params);
|
|
243
247
|
}
|
|
244
248
|
}
|
package/dist/cjs/methods/set.js
CHANGED
|
@@ -55,15 +55,13 @@ const addMethods = (element, parent, options = {}) => {
|
|
|
55
55
|
parseDeep: import__.parseDeep,
|
|
56
56
|
keys: import__.keys,
|
|
57
57
|
nextElement: import__.nextElement,
|
|
58
|
-
previousElement: import__.previousElement
|
|
58
|
+
previousElement: import__.previousElement,
|
|
59
|
+
log: import__.log,
|
|
60
|
+
verbose: import__.verbose,
|
|
61
|
+
warn: import__.warn,
|
|
62
|
+
error: import__.error
|
|
59
63
|
};
|
|
60
64
|
if (element.context.methods)
|
|
61
65
|
(options.strict ? import_utils.merge : import_utils.overwrite)(proto, element.context.methods);
|
|
62
|
-
if ((0, import_utils.isDevelopment)()) {
|
|
63
|
-
proto.log = import__.log;
|
|
64
|
-
proto.verbose = import__.verbose;
|
|
65
|
-
proto.warn = import__.warn;
|
|
66
|
-
proto.error = import__.error;
|
|
67
|
-
}
|
|
68
66
|
Object.setPrototypeOf(element, proto);
|
|
69
67
|
};
|
package/dist/cjs/mixins/data.js
CHANGED
|
@@ -25,8 +25,8 @@ var import_utils = require("@domql/utils");
|
|
|
25
25
|
var import_report = require("@domql/report");
|
|
26
26
|
var data_default = (params, element, node) => {
|
|
27
27
|
if (params) {
|
|
28
|
-
if (element.props.
|
|
29
|
-
(0, import_utils.deepMerge)(params, element.props.
|
|
28
|
+
if (element.props.data)
|
|
29
|
+
(0, import_utils.deepMerge)(params, element.props.data);
|
|
30
30
|
if (params.showOnNode) {
|
|
31
31
|
if (!(0, import_utils.isObject)(params))
|
|
32
32
|
(0, import_report.report)("HTMLInvalidData", params);
|
package/dist/cjs/props/create.js
CHANGED
|
@@ -43,13 +43,18 @@ const createPropsStack = (element, parent) => {
|
|
|
43
43
|
ref.__props = propsStack;
|
|
44
44
|
return propsStack;
|
|
45
45
|
};
|
|
46
|
-
const syncProps = (props, element) => {
|
|
46
|
+
const syncProps = (props, element, opts) => {
|
|
47
47
|
element.props = {};
|
|
48
48
|
const mergedProps = {};
|
|
49
49
|
props.forEach((v) => {
|
|
50
50
|
if (import_ignore.IGNORE_PROPS_PARAMS.includes(v))
|
|
51
51
|
return;
|
|
52
|
-
|
|
52
|
+
let execProps;
|
|
53
|
+
try {
|
|
54
|
+
execProps = (0, import_utils.exec)(v, element);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
element.error(e, opts);
|
|
57
|
+
}
|
|
53
58
|
element.props = (0, import_utils.deepMerge)(
|
|
54
59
|
mergedProps,
|
|
55
60
|
(0, import_utils.deepCloneWithExtend)(execProps, import_ignore.IGNORE_PROPS_PARAMS),
|
|
@@ -61,15 +66,15 @@ const syncProps = (props, element) => {
|
|
|
61
66
|
Object.setPrototypeOf(element.props, methods);
|
|
62
67
|
return element.props;
|
|
63
68
|
};
|
|
64
|
-
const createProps = function(element, parent,
|
|
69
|
+
const createProps = function(element, parent, options) {
|
|
65
70
|
const { __ref: ref } = element;
|
|
66
71
|
const applyProps = () => {
|
|
67
|
-
const propsStack =
|
|
72
|
+
const propsStack = options.cachedProps || createPropsStack(element, parent);
|
|
68
73
|
if (propsStack.length) {
|
|
69
74
|
ref.__props = propsStack;
|
|
70
75
|
syncProps(propsStack, element);
|
|
71
76
|
} else {
|
|
72
|
-
ref.__props =
|
|
77
|
+
ref.__props = options.cachedProps || [];
|
|
73
78
|
element.props = {};
|
|
74
79
|
}
|
|
75
80
|
};
|
|
@@ -80,7 +85,7 @@ const createProps = function(element, parent, cached) {
|
|
|
80
85
|
applyProps();
|
|
81
86
|
} catch {
|
|
82
87
|
element.props = {};
|
|
83
|
-
ref.__props =
|
|
88
|
+
ref.__props = options.cachedProps || [];
|
|
84
89
|
}
|
|
85
90
|
}
|
|
86
91
|
const methods = { update: update.bind(element.props), __element: element };
|
|
@@ -69,7 +69,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
69
69
|
if (element.node && ref.__if) {
|
|
70
70
|
parent[key || element.key] = element;
|
|
71
71
|
}
|
|
72
|
-
(0, import_props.createProps)(element, parent);
|
|
72
|
+
(0, import_props.createProps)(element, parent, options);
|
|
73
73
|
(0, import__2.applyVariant)(element, parent);
|
|
74
74
|
if (element.tag !== "string" && element.tag !== "fragment") {
|
|
75
75
|
(0, import_iterate.throughInitialDefine)(element);
|
package/methods/index.js
CHANGED
|
@@ -136,7 +136,7 @@ export function keys () {
|
|
|
136
136
|
const element = this
|
|
137
137
|
const keys = []
|
|
138
138
|
for (const param in element) {
|
|
139
|
-
if (registry[param] && !parseFilters.elementKeys.includes(param)) { continue }
|
|
139
|
+
if ((registry[param] && !parseFilters.elementKeys.includes(param)) || Object.hasOwnProperty.call(element, param)) { continue }
|
|
140
140
|
keys.push(param)
|
|
141
141
|
}
|
|
142
142
|
return keys
|
|
@@ -159,7 +159,7 @@ export function parse (excl = []) {
|
|
|
159
159
|
} else if (v === 'props') {
|
|
160
160
|
const { __element, update, ...props } = element[v]
|
|
161
161
|
obj[v] = props
|
|
162
|
-
} else if (isDefined(val) &&
|
|
162
|
+
} else if (isDefined(val) && Object.hasOwnProperty.call(element, v)) obj[v] = val
|
|
163
163
|
})
|
|
164
164
|
return obj
|
|
165
165
|
}
|
|
@@ -175,9 +175,11 @@ export function parseDeep (excl = []) {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
export function verbose (...args) {
|
|
178
|
+
if (ENV !== 'test' && ENV !== 'development') return
|
|
179
|
+
|
|
178
180
|
const element = this
|
|
179
181
|
const { __ref: ref } = element
|
|
180
|
-
console.
|
|
182
|
+
console.groupCollapsed(element.key)
|
|
181
183
|
if (args.length) {
|
|
182
184
|
args.forEach(v => console.log(`%c${v}:\n`, 'font-weight: bold', element[v]))
|
|
183
185
|
} else {
|
|
@@ -203,6 +205,7 @@ export function warn (...params) {
|
|
|
203
205
|
|
|
204
206
|
export function error (...params) {
|
|
205
207
|
if (ENV === 'test' || ENV === 'development') {
|
|
208
|
+
if (params[params.length - 1]?.debugger) debugger // eslint-disable-line
|
|
206
209
|
console.error(...params)
|
|
207
210
|
}
|
|
208
211
|
}
|
package/methods/set.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { merge, overwrite } from '@domql/utils'
|
|
4
4
|
|
|
5
5
|
import set, { reset } from '../set'
|
|
6
6
|
import update from '../update'
|
|
@@ -46,14 +46,12 @@ export const addMethods = (element, parent, options = {}) => {
|
|
|
46
46
|
parseDeep,
|
|
47
47
|
keys,
|
|
48
48
|
nextElement,
|
|
49
|
-
previousElement
|
|
49
|
+
previousElement,
|
|
50
|
+
log,
|
|
51
|
+
verbose,
|
|
52
|
+
warn,
|
|
53
|
+
error
|
|
50
54
|
}
|
|
51
55
|
if (element.context.methods) (options.strict ? merge : overwrite)(proto, element.context.methods)
|
|
52
|
-
if (isDevelopment()) {
|
|
53
|
-
proto.log = log
|
|
54
|
-
proto.verbose = verbose
|
|
55
|
-
proto.warn = warn
|
|
56
|
-
proto.error = error
|
|
57
|
-
}
|
|
58
56
|
Object.setPrototypeOf(element, proto)
|
|
59
57
|
}
|
package/mixins/data.js
CHANGED
|
@@ -9,7 +9,7 @@ import { report } from '@domql/report'
|
|
|
9
9
|
*/
|
|
10
10
|
export default (params, element, node) => {
|
|
11
11
|
if (params) {
|
|
12
|
-
if (element.props.
|
|
12
|
+
if (element.props.data) deepMerge(params, element.props.data)
|
|
13
13
|
if (params.showOnNode) {
|
|
14
14
|
if (!isObject(params)) report('HTMLInvalidData', params)
|
|
15
15
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.150",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@domql/event": "^2.5.
|
|
30
|
-
"@domql/render": "^2.5.
|
|
31
|
-
"@domql/state": "^2.5.
|
|
32
|
-
"@domql/utils": "^2.5.
|
|
29
|
+
"@domql/event": "^2.5.150",
|
|
30
|
+
"@domql/render": "^2.5.150",
|
|
31
|
+
"@domql/state": "^2.5.150",
|
|
32
|
+
"@domql/utils": "^2.5.150"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "8e04bcc422d23520fd394f79be15dc4336cd59a6",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|
package/props/create.js
CHANGED
|
@@ -24,13 +24,16 @@ const createPropsStack = (element, parent) => {
|
|
|
24
24
|
return propsStack
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const syncProps = (props, element) => {
|
|
27
|
+
export const syncProps = (props, element, opts) => {
|
|
28
28
|
element.props = {}
|
|
29
29
|
const mergedProps = {}
|
|
30
30
|
|
|
31
31
|
props.forEach(v => {
|
|
32
32
|
if (IGNORE_PROPS_PARAMS.includes(v)) return
|
|
33
|
-
|
|
33
|
+
let execProps
|
|
34
|
+
try {
|
|
35
|
+
execProps = exec(v, element)
|
|
36
|
+
} catch (e) { element.error(e, opts) }
|
|
34
37
|
// TODO: check if this failing the function props merge
|
|
35
38
|
// if (isObject(execProps) && execProps.__element) return
|
|
36
39
|
// it was causing infinite loop at early days
|
|
@@ -48,16 +51,16 @@ export const syncProps = (props, element) => {
|
|
|
48
51
|
return element.props
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
export const createProps = function (element, parent,
|
|
54
|
+
export const createProps = function (element, parent, options) {
|
|
52
55
|
const { __ref: ref } = element
|
|
53
56
|
|
|
54
57
|
const applyProps = () => {
|
|
55
|
-
const propsStack =
|
|
58
|
+
const propsStack = options.cachedProps || createPropsStack(element, parent)
|
|
56
59
|
if (propsStack.length) {
|
|
57
60
|
ref.__props = propsStack
|
|
58
61
|
syncProps(propsStack, element)
|
|
59
62
|
} else {
|
|
60
|
-
ref.__props =
|
|
63
|
+
ref.__props = options.cachedProps || []
|
|
61
64
|
element.props = {}
|
|
62
65
|
}
|
|
63
66
|
}
|
|
@@ -68,7 +71,7 @@ export const createProps = function (element, parent, cached) {
|
|
|
68
71
|
applyProps()
|
|
69
72
|
} catch {
|
|
70
73
|
element.props = {}
|
|
71
|
-
ref.__props =
|
|
74
|
+
ref.__props = options.cachedProps || []
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
|
|
@@ -70,7 +70,7 @@ export const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
70
70
|
|
|
71
71
|
if (element.node && ref.__if) { parent[key || element.key] = element } // Borrowed from assignNode()
|
|
72
72
|
|
|
73
|
-
createProps(element, parent)
|
|
73
|
+
createProps(element, parent, options)
|
|
74
74
|
applyVariant(element, parent)
|
|
75
75
|
|
|
76
76
|
if (element.tag !== 'string' && element.tag !== 'fragment') {
|