@domql/element 2.5.146 → 2.5.148
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 +7 -5
- package/dist/cjs/create.js +10 -6
- package/dist/cjs/methods/index.js +58 -37
- package/dist/cjs/methods/set.js +7 -3
- package/dist/cjs/update.js +1 -1
- package/dist/cjs/utils/onlyResolveExtends.js +1 -1
- package/methods/index.js +43 -23
- package/methods/set.js +12 -4
- package/package.json +6 -6
- package/update.js +2 -2
- package/utils/onlyResolveExtends.js +1 -1
package/create.js
CHANGED
|
@@ -80,7 +80,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}, attachOpti
|
|
|
80
80
|
|
|
81
81
|
addCaching(element, parent)
|
|
82
82
|
|
|
83
|
-
addMethods(element, parent)
|
|
83
|
+
addMethods(element, parent, options)
|
|
84
84
|
|
|
85
85
|
createScope(element, parent)
|
|
86
86
|
|
|
@@ -232,9 +232,11 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
232
232
|
if (path.includes('ComponentsGrid')) path.splice(0, path.indexOf('ComponentsGrid') + 2)
|
|
233
233
|
if (path.includes('demoComponent')) path.splice(0, path.indexOf('demoComponent') + 1)
|
|
234
234
|
const isDemoComponent = element.lookup(el => el.state.key)?.state?.key
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
element.warn('Error happened in:', isDemoComponent ? isDemoComponent + ' ' : '' + path.join('.'))
|
|
236
|
+
element.verbose()
|
|
237
|
+
element.error(e)
|
|
238
|
+
if (element.on?.error) element.on.error(e, element, element.state, element.context, options)
|
|
239
|
+
if (element.props?.onError) element.props.onError(e, element, element.state, element.context, options)
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
242
|
|
|
@@ -342,7 +344,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
342
344
|
if (!ref.__skipCreate) {
|
|
343
345
|
addCaching(element, parent)
|
|
344
346
|
|
|
345
|
-
addMethods(element, parent)
|
|
347
|
+
addMethods(element, parent, options)
|
|
346
348
|
|
|
347
349
|
createScope(element, parent)
|
|
348
350
|
|
package/dist/cjs/create.js
CHANGED
|
@@ -68,7 +68,7 @@ const create = (element, parent, key, options = import_options.default.create ||
|
|
|
68
68
|
}
|
|
69
69
|
switchDefaultOptions(element, parent, options);
|
|
70
70
|
addCaching(element, parent);
|
|
71
|
-
(0, import_set.addMethods)(element, parent);
|
|
71
|
+
(0, import_set.addMethods)(element, parent, options);
|
|
72
72
|
createScope(element, parent);
|
|
73
73
|
(0, import_state.createState)(element, parent);
|
|
74
74
|
if (element.scope === "state")
|
|
@@ -169,7 +169,7 @@ const addElementIntoParentChildren = (element, parent) => {
|
|
|
169
169
|
};
|
|
170
170
|
const visitedElements = /* @__PURE__ */ new WeakMap();
|
|
171
171
|
const renderElement = (element, parent, options, attachOptions) => {
|
|
172
|
-
var _a, _b;
|
|
172
|
+
var _a, _b, _c, _d;
|
|
173
173
|
if (visitedElements.has(element)) {
|
|
174
174
|
if (ENV === "test" || ENV === "development")
|
|
175
175
|
console.warn("Cyclic rendering detected:", element.__ref.path);
|
|
@@ -190,9 +190,13 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
190
190
|
if (path.includes("demoComponent"))
|
|
191
191
|
path.splice(0, path.indexOf("demoComponent") + 1);
|
|
192
192
|
const isDemoComponent = (_b = (_a = element.lookup((el) => el.state.key)) == null ? void 0 : _a.state) == null ? void 0 : _b.key;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
element.warn("Error happened in:", isDemoComponent ? isDemoComponent + " " : "" + path.join("."));
|
|
194
|
+
element.verbose();
|
|
195
|
+
element.error(e);
|
|
196
|
+
if ((_c = element.on) == null ? void 0 : _c.error)
|
|
197
|
+
element.on.error(e, element, element.state, element.context, options);
|
|
198
|
+
if ((_d = element.props) == null ? void 0 : _d.onError)
|
|
199
|
+
element.props.onError(e, element, element.state, element.context, options);
|
|
196
200
|
}
|
|
197
201
|
}
|
|
198
202
|
if (!ref.__if) {
|
|
@@ -273,7 +277,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
273
277
|
const { __ref: ref } = element;
|
|
274
278
|
if (!ref.__skipCreate) {
|
|
275
279
|
addCaching(element, parent);
|
|
276
|
-
(0, import_set.addMethods)(element, parent);
|
|
280
|
+
(0, import_set.addMethods)(element, parent, options);
|
|
277
281
|
createScope(element, parent);
|
|
278
282
|
(0, import_state.createState)(element, parent);
|
|
279
283
|
if (element.scope === "state")
|
|
@@ -20,6 +20,7 @@ var methods_exports = {};
|
|
|
20
20
|
__export(methods_exports, {
|
|
21
21
|
METHODS: () => METHODS,
|
|
22
22
|
defineSetter: () => defineSetter,
|
|
23
|
+
error: () => error,
|
|
23
24
|
get: () => get,
|
|
24
25
|
isMethod: () => isMethod,
|
|
25
26
|
keys: () => keys,
|
|
@@ -35,13 +36,16 @@ __export(methods_exports, {
|
|
|
35
36
|
setNodeStyles: () => setNodeStyles,
|
|
36
37
|
setProps: () => setProps,
|
|
37
38
|
spotByPath: () => spotByPath,
|
|
38
|
-
variables: () => variables
|
|
39
|
+
variables: () => variables,
|
|
40
|
+
verbose: () => verbose,
|
|
41
|
+
warn: () => warn
|
|
39
42
|
});
|
|
40
43
|
module.exports = __toCommonJS(methods_exports);
|
|
41
44
|
var import_utils = require("@domql/utils");
|
|
42
45
|
var import_tree = require("../tree");
|
|
43
46
|
var import_mixins = require("../mixins");
|
|
44
|
-
const
|
|
47
|
+
const ENV = "development";
|
|
48
|
+
function spotByPath(path) {
|
|
45
49
|
const element = this;
|
|
46
50
|
const arr = [].concat(path);
|
|
47
51
|
let active = import_tree.TREE[arr[0]];
|
|
@@ -56,8 +60,8 @@ const spotByPath = function(path) {
|
|
|
56
60
|
return;
|
|
57
61
|
}
|
|
58
62
|
return active;
|
|
59
|
-
}
|
|
60
|
-
|
|
63
|
+
}
|
|
64
|
+
function lookup(param) {
|
|
61
65
|
const el = this;
|
|
62
66
|
let { parent } = el;
|
|
63
67
|
if ((0, import_utils.isFunction)(param)) {
|
|
@@ -78,8 +82,8 @@ const lookup = function(param) {
|
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
80
84
|
return parent;
|
|
81
|
-
}
|
|
82
|
-
|
|
85
|
+
}
|
|
86
|
+
function lookdown(param) {
|
|
83
87
|
var _a;
|
|
84
88
|
const el = this;
|
|
85
89
|
const { __ref: ref } = el;
|
|
@@ -99,9 +103,8 @@ const lookdown = function(param) {
|
|
|
99
103
|
if (lookdown2)
|
|
100
104
|
return lookdown2;
|
|
101
105
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const lookdownAll = function(param, results = []) {
|
|
106
|
+
}
|
|
107
|
+
function lookdownAll(param, results = []) {
|
|
105
108
|
var _a;
|
|
106
109
|
const el = this;
|
|
107
110
|
const { __ref: ref } = el;
|
|
@@ -118,9 +121,9 @@ const lookdownAll = function(param, results = []) {
|
|
|
118
121
|
}
|
|
119
122
|
(_a = childElem == null ? void 0 : childElem.lookdownAll) == null ? void 0 : _a.call(childElem, param, results);
|
|
120
123
|
}
|
|
121
|
-
return results.length ? results :
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
+
return results.length ? results : void 0;
|
|
125
|
+
}
|
|
126
|
+
function setNodeStyles(params = {}) {
|
|
124
127
|
var _a;
|
|
125
128
|
const el = this;
|
|
126
129
|
if (!((_a = el.node) == null ? void 0 : _a.style))
|
|
@@ -134,8 +137,8 @@ const setNodeStyles = function(params = {}) {
|
|
|
134
137
|
el.node.style[param] = value;
|
|
135
138
|
}
|
|
136
139
|
return el;
|
|
137
|
-
}
|
|
138
|
-
|
|
140
|
+
}
|
|
141
|
+
function remove() {
|
|
139
142
|
const element = this;
|
|
140
143
|
if ((0, import_utils.isFunction)(element.node.remove))
|
|
141
144
|
element.node.remove();
|
|
@@ -146,20 +149,20 @@ const remove = function() {
|
|
|
146
149
|
delete element.parent[element.key];
|
|
147
150
|
if (element.parent.__ref)
|
|
148
151
|
element.parent.__ref.__children = (0, import_utils.removeValueFromArray)(element.parent.__ref.__children, element.key);
|
|
149
|
-
}
|
|
150
|
-
|
|
152
|
+
}
|
|
153
|
+
function get(param) {
|
|
151
154
|
const element = this;
|
|
152
155
|
return element[param];
|
|
153
|
-
}
|
|
154
|
-
|
|
156
|
+
}
|
|
157
|
+
function setProps(param, options) {
|
|
155
158
|
const element = this;
|
|
156
159
|
if (!param || !element.props)
|
|
157
160
|
return;
|
|
158
161
|
element.update({ props: param }, options);
|
|
159
162
|
return element;
|
|
160
|
-
}
|
|
163
|
+
}
|
|
161
164
|
const defineSetter = (element, key, get2, set) => Object.defineProperty(element, key, { get: get2, set });
|
|
162
|
-
|
|
165
|
+
function keys() {
|
|
163
166
|
const element = this;
|
|
164
167
|
const keys2 = [];
|
|
165
168
|
for (const param in element) {
|
|
@@ -169,8 +172,8 @@ const keys = function() {
|
|
|
169
172
|
keys2.push(param);
|
|
170
173
|
}
|
|
171
174
|
return keys2;
|
|
172
|
-
}
|
|
173
|
-
|
|
175
|
+
}
|
|
176
|
+
function parse(excl = []) {
|
|
174
177
|
const element = this;
|
|
175
178
|
const obj = {};
|
|
176
179
|
const keyList = keys.call(element);
|
|
@@ -195,8 +198,8 @@ const parse = function(excl = []) {
|
|
|
195
198
|
obj[v] = val;
|
|
196
199
|
});
|
|
197
200
|
return obj;
|
|
198
|
-
}
|
|
199
|
-
|
|
201
|
+
}
|
|
202
|
+
function parseDeep(excl = []) {
|
|
200
203
|
const element = this;
|
|
201
204
|
const obj = parse.call(element, excl);
|
|
202
205
|
for (const v in obj) {
|
|
@@ -207,32 +210,47 @@ const parseDeep = function(excl = []) {
|
|
|
207
210
|
}
|
|
208
211
|
}
|
|
209
212
|
return obj;
|
|
210
|
-
}
|
|
211
|
-
|
|
213
|
+
}
|
|
214
|
+
function verbose(...args) {
|
|
212
215
|
const element = this;
|
|
213
|
-
const { __ref } = element;
|
|
216
|
+
const { __ref: ref } = element;
|
|
214
217
|
console.group(element.key);
|
|
215
218
|
if (args.length) {
|
|
216
219
|
args.forEach((v) => console.log(`%c${v}:
|
|
217
220
|
`, "font-weight: bold", element[v]));
|
|
218
221
|
} else {
|
|
219
|
-
console.log(
|
|
222
|
+
console.log(ref.path);
|
|
220
223
|
const keys2 = element.keys();
|
|
221
224
|
keys2.forEach((v) => console.log(`%c${v}:
|
|
222
225
|
`, "font-weight: bold", element[v]));
|
|
223
226
|
}
|
|
224
227
|
console.groupEnd(element.key);
|
|
225
228
|
return element;
|
|
226
|
-
}
|
|
227
|
-
|
|
229
|
+
}
|
|
230
|
+
function log(...params) {
|
|
231
|
+
if (ENV === "test" || ENV === "development") {
|
|
232
|
+
console.log(...params);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function warn(...params) {
|
|
236
|
+
if (ENV === "test" || ENV === "development") {
|
|
237
|
+
console.warn(...params);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function error(...params) {
|
|
241
|
+
if (ENV === "test" || ENV === "development") {
|
|
242
|
+
console.error(...params);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function nextElement() {
|
|
228
246
|
const element = this;
|
|
229
247
|
const { key, parent } = element;
|
|
230
248
|
const { __children } = parent.__ref;
|
|
231
249
|
const currentIndex = __children.indexOf(key);
|
|
232
250
|
const nextChild = __children[currentIndex + 1];
|
|
233
251
|
return parent[nextChild];
|
|
234
|
-
}
|
|
235
|
-
|
|
252
|
+
}
|
|
253
|
+
function previousElement(el) {
|
|
236
254
|
const element = el || this;
|
|
237
255
|
const { key, parent } = element;
|
|
238
256
|
const { __children } = parent.__ref;
|
|
@@ -240,8 +258,8 @@ const previousElement = function(el) {
|
|
|
240
258
|
return;
|
|
241
259
|
const currentIndex = __children.indexOf(key);
|
|
242
260
|
return parent[__children[currentIndex - 1]];
|
|
243
|
-
}
|
|
244
|
-
|
|
261
|
+
}
|
|
262
|
+
function variables(obj = {}) {
|
|
245
263
|
const element = this;
|
|
246
264
|
if (!element.data)
|
|
247
265
|
element.data = {};
|
|
@@ -275,7 +293,7 @@ const variables = function(obj = {}) {
|
|
|
275
293
|
}, timeout);
|
|
276
294
|
}
|
|
277
295
|
};
|
|
278
|
-
}
|
|
296
|
+
}
|
|
279
297
|
const METHODS = [
|
|
280
298
|
"set",
|
|
281
299
|
"reset",
|
|
@@ -295,10 +313,13 @@ const METHODS = [
|
|
|
295
313
|
"variables",
|
|
296
314
|
"if",
|
|
297
315
|
"log",
|
|
316
|
+
"verbose",
|
|
317
|
+
"warn",
|
|
318
|
+
"error",
|
|
298
319
|
"nextElement",
|
|
299
320
|
"previousElement"
|
|
300
321
|
];
|
|
301
|
-
|
|
322
|
+
function isMethod(param, element) {
|
|
302
323
|
var _a, _b;
|
|
303
324
|
return METHODS.includes(param) || ((_b = (_a = element == null ? void 0 : element.context) == null ? void 0 : _a.methods) == null ? void 0 : _b[param]);
|
|
304
|
-
}
|
|
325
|
+
}
|
package/dist/cjs/methods/set.js
CHANGED
|
@@ -36,7 +36,7 @@ var import_set = __toESM(require("../set"), 1);
|
|
|
36
36
|
var import_update = __toESM(require("../update"), 1);
|
|
37
37
|
var import__ = require("./");
|
|
38
38
|
var import_content = require("../mixins/content");
|
|
39
|
-
const addMethods = (element, parent, options) => {
|
|
39
|
+
const addMethods = (element, parent, options = {}) => {
|
|
40
40
|
const proto = {
|
|
41
41
|
set: import_set.default,
|
|
42
42
|
reset: import_set.reset,
|
|
@@ -58,8 +58,12 @@ const addMethods = (element, parent, options) => {
|
|
|
58
58
|
previousElement: import__.previousElement
|
|
59
59
|
};
|
|
60
60
|
if (element.context.methods)
|
|
61
|
-
(
|
|
62
|
-
if ((0, import_utils.isDevelopment)())
|
|
61
|
+
(options.strict ? import_utils.merge : import_utils.overwrite)(proto, element.context.methods);
|
|
62
|
+
if ((0, import_utils.isDevelopment)()) {
|
|
63
63
|
proto.log = import__.log;
|
|
64
|
+
proto.verbose = import__.verbose;
|
|
65
|
+
proto.warn = import__.warn;
|
|
66
|
+
proto.error = import__.error;
|
|
67
|
+
}
|
|
64
68
|
Object.setPrototypeOf(element, proto);
|
|
65
69
|
};
|
package/dist/cjs/update.js
CHANGED
|
@@ -93,7 +93,7 @@ const update = function(params = {}, opts) {
|
|
|
93
93
|
if (beforeUpdateReturns === false)
|
|
94
94
|
return element;
|
|
95
95
|
}
|
|
96
|
-
(0, import_utils.overwriteDeep)(element, params, import_utils2.METHODS_EXL);
|
|
96
|
+
(0, import_utils.overwriteDeep)(element, params, { exclude: import_utils2.METHODS_EXL });
|
|
97
97
|
(0, import_iterate.throughExecProps)(element);
|
|
98
98
|
(0, import_iterate.throughUpdatedExec)(element, { ignore: UPDATE_DEFAULT_OPTIONS });
|
|
99
99
|
(0, import_iterate.throughUpdatedDefine)(element);
|
|
@@ -55,7 +55,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
55
55
|
if (!ref2.__children)
|
|
56
56
|
ref2.__children = [];
|
|
57
57
|
}
|
|
58
|
-
(0, import_set.addMethods)(element, parent);
|
|
58
|
+
(0, import_set.addMethods)(element, parent, options);
|
|
59
59
|
(0, import_state.createState)(element, parent);
|
|
60
60
|
const ref = __ref;
|
|
61
61
|
if ((0, import_utils.isFunction)(element.if)) {
|
package/methods/index.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
import { isDefined, isObject, isFunction, isObjectLike, isProduction, removeValueFromArray, deepClone } from '@domql/utils'
|
|
4
4
|
import { TREE } from '../tree'
|
|
5
5
|
import { parseFilters, registry } from '../mixins'
|
|
6
|
+
const ENV = process.env.NODE_ENV
|
|
6
7
|
|
|
7
8
|
// TODO: update these files
|
|
8
|
-
export
|
|
9
|
+
export function spotByPath (path) {
|
|
9
10
|
const element = this
|
|
10
11
|
const arr = [].concat(path)
|
|
11
12
|
let active = TREE[arr[0]]
|
|
@@ -23,7 +24,7 @@ export const spotByPath = function (path) {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
// TODO: update these files
|
|
26
|
-
export
|
|
27
|
+
export function lookup (param) {
|
|
27
28
|
const el = this
|
|
28
29
|
let { parent } = el
|
|
29
30
|
|
|
@@ -44,7 +45,7 @@ export const lookup = function (param) {
|
|
|
44
45
|
return parent
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
export
|
|
48
|
+
export function lookdown (param) {
|
|
48
49
|
const el = this
|
|
49
50
|
const { __ref: ref } = el
|
|
50
51
|
const children = ref.__children
|
|
@@ -63,11 +64,9 @@ export const lookdown = function (param) {
|
|
|
63
64
|
const lookdown = childElem?.lookdown?.(param)
|
|
64
65
|
if (lookdown) return lookdown
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
return null
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
export
|
|
69
|
+
export function lookdownAll (param, results = []) {
|
|
71
70
|
const el = this
|
|
72
71
|
const { __ref: ref } = el
|
|
73
72
|
const children = ref.__children
|
|
@@ -84,10 +83,10 @@ export const lookdownAll = function (param, results = []) {
|
|
|
84
83
|
childElem?.lookdownAll?.(param, results)
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
return results.length ? results :
|
|
86
|
+
return results.length ? results : undefined
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
export
|
|
89
|
+
export function setNodeStyles (params = {}) {
|
|
91
90
|
const el = this
|
|
92
91
|
if (!el.node?.style) return
|
|
93
92
|
|
|
@@ -101,7 +100,7 @@ export const setNodeStyles = function (params = {}) {
|
|
|
101
100
|
return el
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
export
|
|
103
|
+
export function remove () {
|
|
105
104
|
const element = this
|
|
106
105
|
if (isFunction(element.node.remove)) element.node.remove()
|
|
107
106
|
else if (!isProduction()) {
|
|
@@ -112,28 +111,28 @@ export const remove = function () {
|
|
|
112
111
|
if (element.parent.__ref) element.parent.__ref.__children = removeValueFromArray(element.parent.__ref.__children, element.key)
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
export
|
|
114
|
+
export function get (param) {
|
|
116
115
|
const element = this
|
|
117
116
|
return element[param]
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
export
|
|
119
|
+
export function setProps (param, options) {
|
|
121
120
|
const element = this
|
|
122
121
|
if (!param || !element.props) return
|
|
123
122
|
element.update({ props: param }, options)
|
|
124
123
|
return element
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
// export
|
|
126
|
+
// export function set () {
|
|
128
127
|
// }
|
|
129
128
|
|
|
130
|
-
// export
|
|
129
|
+
// export function update () {
|
|
131
130
|
// }
|
|
132
131
|
|
|
133
132
|
export const defineSetter = (element, key, get, set) =>
|
|
134
133
|
Object.defineProperty(element, key, { get, set })
|
|
135
134
|
|
|
136
|
-
export
|
|
135
|
+
export function keys () {
|
|
137
136
|
const element = this
|
|
138
137
|
const keys = []
|
|
139
138
|
for (const param in element) {
|
|
@@ -143,7 +142,7 @@ export const keys = function () {
|
|
|
143
142
|
return keys
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
export
|
|
145
|
+
export function parse (excl = []) {
|
|
147
146
|
const element = this
|
|
148
147
|
const obj = {}
|
|
149
148
|
const keyList = keys.call(element)
|
|
@@ -165,7 +164,7 @@ export const parse = function (excl = []) {
|
|
|
165
164
|
return obj
|
|
166
165
|
}
|
|
167
166
|
|
|
168
|
-
export
|
|
167
|
+
export function parseDeep (excl = []) {
|
|
169
168
|
const element = this
|
|
170
169
|
const obj = parse.call(element, excl)
|
|
171
170
|
for (const v in obj) {
|
|
@@ -175,14 +174,14 @@ export const parseDeep = function (excl = []) {
|
|
|
175
174
|
return obj
|
|
176
175
|
}
|
|
177
176
|
|
|
178
|
-
export
|
|
177
|
+
export function verbose (...args) {
|
|
179
178
|
const element = this
|
|
180
|
-
const { __ref } = element
|
|
179
|
+
const { __ref: ref } = element
|
|
181
180
|
console.group(element.key)
|
|
182
181
|
if (args.length) {
|
|
183
182
|
args.forEach(v => console.log(`%c${v}:\n`, 'font-weight: bold', element[v]))
|
|
184
183
|
} else {
|
|
185
|
-
console.log(
|
|
184
|
+
console.log(ref.path)
|
|
186
185
|
const keys = element.keys()
|
|
187
186
|
keys.forEach(v => console.log(`%c${v}:\n`, 'font-weight: bold', element[v]))
|
|
188
187
|
}
|
|
@@ -190,7 +189,25 @@ export const log = function (...args) {
|
|
|
190
189
|
return element
|
|
191
190
|
}
|
|
192
191
|
|
|
193
|
-
export
|
|
192
|
+
export function log (...params) {
|
|
193
|
+
if (ENV === 'test' || ENV === 'development') {
|
|
194
|
+
console.log(...params)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function warn (...params) {
|
|
199
|
+
if (ENV === 'test' || ENV === 'development') {
|
|
200
|
+
console.warn(...params)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function error (...params) {
|
|
205
|
+
if (ENV === 'test' || ENV === 'development') {
|
|
206
|
+
console.error(...params)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function nextElement () {
|
|
194
211
|
const element = this
|
|
195
212
|
const { key, parent } = element
|
|
196
213
|
const { __children } = parent.__ref
|
|
@@ -201,7 +218,7 @@ export const nextElement = function () {
|
|
|
201
218
|
return parent[nextChild]
|
|
202
219
|
}
|
|
203
220
|
|
|
204
|
-
export
|
|
221
|
+
export function previousElement (el) {
|
|
205
222
|
const element = el || this
|
|
206
223
|
const { key, parent } = element
|
|
207
224
|
const { __children } = parent.__ref
|
|
@@ -212,7 +229,7 @@ export const previousElement = function (el) {
|
|
|
212
229
|
return parent[__children[currentIndex - 1]]
|
|
213
230
|
}
|
|
214
231
|
|
|
215
|
-
export
|
|
232
|
+
export function variables (obj = {}) {
|
|
216
233
|
const element = this
|
|
217
234
|
if (!element.data) element.data = {}
|
|
218
235
|
if (!element.data.varCaches) element.data.varCaches = {}
|
|
@@ -263,10 +280,13 @@ export const METHODS = [
|
|
|
263
280
|
'variables',
|
|
264
281
|
'if',
|
|
265
282
|
'log',
|
|
283
|
+
'verbose',
|
|
284
|
+
'warn',
|
|
285
|
+
'error',
|
|
266
286
|
'nextElement',
|
|
267
287
|
'previousElement'
|
|
268
288
|
]
|
|
269
289
|
|
|
270
|
-
export
|
|
290
|
+
export function isMethod (param, element) {
|
|
271
291
|
return METHODS.includes(param) || element?.context?.methods?.[param]
|
|
272
292
|
}
|
package/methods/set.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isDevelopment, merge } from '@domql/utils'
|
|
3
|
+
import { isDevelopment, merge, overwrite } from '@domql/utils'
|
|
4
4
|
|
|
5
5
|
import set, { reset } from '../set'
|
|
6
6
|
import update from '../update'
|
|
@@ -14,6 +14,9 @@ import {
|
|
|
14
14
|
remove,
|
|
15
15
|
spotByPath,
|
|
16
16
|
log,
|
|
17
|
+
verbose,
|
|
18
|
+
warn,
|
|
19
|
+
error,
|
|
17
20
|
variables,
|
|
18
21
|
keys,
|
|
19
22
|
parse,
|
|
@@ -24,7 +27,7 @@ import {
|
|
|
24
27
|
|
|
25
28
|
import { removeContent, updateContent } from '../mixins/content'
|
|
26
29
|
|
|
27
|
-
export const addMethods = (element, parent, options) => {
|
|
30
|
+
export const addMethods = (element, parent, options = {}) => {
|
|
28
31
|
const proto = {
|
|
29
32
|
set,
|
|
30
33
|
reset,
|
|
@@ -45,7 +48,12 @@ export const addMethods = (element, parent, options) => {
|
|
|
45
48
|
nextElement,
|
|
46
49
|
previousElement
|
|
47
50
|
}
|
|
48
|
-
if (element.context.methods) merge(proto, element.context.methods)
|
|
49
|
-
if (isDevelopment())
|
|
51
|
+
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
|
+
}
|
|
50
58
|
Object.setPrototypeOf(element, proto)
|
|
51
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.148",
|
|
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.148",
|
|
30
|
+
"@domql/render": "^2.5.148",
|
|
31
|
+
"@domql/state": "^2.5.148",
|
|
32
|
+
"@domql/utils": "^2.5.148"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "6706914c73f3c9669ff443c0c890dea1f4e908ab",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|
package/update.js
CHANGED
|
@@ -80,7 +80,7 @@ const update = function (params = {}, opts) {
|
|
|
80
80
|
if (beforeUpdateReturns === false) return element
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
overwriteDeep(element, params, METHODS_EXL)
|
|
83
|
+
overwriteDeep(element, params, { exclude: METHODS_EXL })
|
|
84
84
|
throughExecProps(element)
|
|
85
85
|
throughUpdatedExec(element, { ignore: UPDATE_DEFAULT_OPTIONS })
|
|
86
86
|
throughUpdatedDefine(element)
|
|
@@ -312,7 +312,7 @@ const createStateUpdate = (element, parent, options) => {
|
|
|
312
312
|
export default update
|
|
313
313
|
|
|
314
314
|
// save updates history
|
|
315
|
-
// const overwriteChanges = overwriteDeep(element, params, METHODS_EXL)
|
|
315
|
+
// const overwriteChanges = overwriteDeep(element, params, { exclude: METHODS_EXL })
|
|
316
316
|
// // const overwriteChanges = overwriteDeep(element, params)
|
|
317
317
|
// const propsChanges = throughExecProps(element)
|
|
318
318
|
// const execChanges = throughUpdatedExec(element, { ignore: UPDATE_DEFAULT_OPTIONS })
|