@domql/element 2.5.141 → 2.5.142
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 +4 -1
- package/dist/cjs/create.js +2 -1
- package/dist/cjs/extend.js +3 -3
- package/dist/cjs/iterate.js +2 -2
- package/dist/cjs/methods/index.js +3 -2
- package/dist/cjs/methods/set.js +2 -0
- package/dist/cjs/node.js +1 -1
- package/dist/cjs/update.js +5 -5
- package/dist/cjs/utils/component.js +5 -0
- package/dist/cjs/utils/onlyResolveExtends.js +1 -1
- package/extend.js +3 -5
- package/iterate.js +2 -2
- package/methods/index.js +2 -2
- package/methods/set.js +2 -1
- package/node.js +1 -1
- package/package.json +6 -6
- package/update.js +2 -2
- package/utils/component.js +7 -0
- package/utils/onlyResolveExtends.js +1 -1
package/create.js
CHANGED
|
@@ -252,6 +252,9 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
252
252
|
|
|
253
253
|
// run `on.done`
|
|
254
254
|
triggerEventOn('done', element, options)
|
|
255
|
+
|
|
256
|
+
// run `on.done`
|
|
257
|
+
triggerEventOn('create', element, options)
|
|
255
258
|
}
|
|
256
259
|
|
|
257
260
|
const checkIfPrimitive = (element) => is(element)('string', 'number')
|
|
@@ -362,7 +365,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
362
365
|
for (const k in element) {
|
|
363
366
|
if (
|
|
364
367
|
isUndefined(element[k]) ||
|
|
365
|
-
isMethod(k) ||
|
|
368
|
+
isMethod(k, element) ||
|
|
366
369
|
isObject(registry[k]) ||
|
|
367
370
|
isVariant(k)
|
|
368
371
|
) continue
|
package/dist/cjs/create.js
CHANGED
|
@@ -203,6 +203,7 @@ const renderElement = (element, parent, options, attachOptions) => {
|
|
|
203
203
|
(0, import_event.triggerEventOn)("renderRouter", element, options);
|
|
204
204
|
(0, import_event.triggerEventOn)("render", element, options);
|
|
205
205
|
(0, import_event.triggerEventOn)("done", element, options);
|
|
206
|
+
(0, import_event.triggerEventOn)("create", element, options);
|
|
206
207
|
};
|
|
207
208
|
const checkIfPrimitive = (element) => (0, import_utils.is)(element)("string", "number");
|
|
208
209
|
const applyValueAsText = (element, parent, key) => {
|
|
@@ -290,7 +291,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
290
291
|
(0, import_iterate.throughInitialDefine)(element);
|
|
291
292
|
(0, import_iterate.throughInitialExec)(element);
|
|
292
293
|
for (const k in element) {
|
|
293
|
-
if ((0, import_utils.isUndefined)(element[k]) || (0, import_methods.isMethod)(k) || (0, import_utils.isObject)(import_mixins.registry[k]) || (0, import_utils.isVariant)(k))
|
|
294
|
+
if ((0, import_utils.isUndefined)(element[k]) || (0, import_methods.isMethod)(k, element) || (0, import_utils.isObject)(import_mixins.registry[k]) || (0, import_utils.isVariant)(k))
|
|
294
295
|
continue;
|
|
295
296
|
const hasDefine = element.define && element.define[k];
|
|
296
297
|
const contextHasDefine = element.context && element.context.define && element.context.define[k];
|
package/dist/cjs/extend.js
CHANGED
|
@@ -60,11 +60,11 @@ const applyExtend = (element, parent, options = {}) => {
|
|
|
60
60
|
stack = extendStack;
|
|
61
61
|
} else if (childExtendLength) {
|
|
62
62
|
stack = childExtendStack;
|
|
63
|
-
} else if (!
|
|
63
|
+
} else if (!context.defaultExtends)
|
|
64
64
|
return element;
|
|
65
|
-
if (
|
|
65
|
+
if (context.defaultExtends) {
|
|
66
66
|
if (!mainExtend) {
|
|
67
|
-
const defaultOptionsExtend = (0, import_utils2.getExtendStack)(
|
|
67
|
+
const defaultOptionsExtend = (0, import_utils2.getExtendStack)(context.defaultExtends, context);
|
|
68
68
|
mainExtend = (0, import_utils2.cloneAndMergeArrayExtend)(defaultOptionsExtend);
|
|
69
69
|
delete mainExtend.extend;
|
|
70
70
|
}
|
package/dist/cjs/iterate.js
CHANGED
|
@@ -33,7 +33,7 @@ const throughInitialExec = (element, exclude = {}) => {
|
|
|
33
33
|
if (exclude[param])
|
|
34
34
|
continue;
|
|
35
35
|
const prop = element[param];
|
|
36
|
-
if ((0, import_utils.isFunction)(prop) && !(0, import_methods.isMethod)(param) && !(0, import_utils.isVariant)(param)) {
|
|
36
|
+
if ((0, import_utils.isFunction)(prop) && !(0, import_methods.isMethod)(param, element) && !(0, import_utils.isVariant)(param)) {
|
|
37
37
|
ref.__exec[param] = prop;
|
|
38
38
|
element[param] = prop(element, element.state, element.context);
|
|
39
39
|
}
|
|
@@ -73,7 +73,7 @@ const throughInitialDefine = (element) => {
|
|
|
73
73
|
defineObj = { ...defineObj, ...context.define };
|
|
74
74
|
for (const param in defineObj) {
|
|
75
75
|
let elementProp = element[param];
|
|
76
|
-
if ((0, import_utils.isFunction)(elementProp) && !(0, import_methods.isMethod)(param) && !(0, import_utils.isVariant)(param)) {
|
|
76
|
+
if ((0, import_utils.isFunction)(elementProp) && !(0, import_methods.isMethod)(param, element) && !(0, import_utils.isVariant)(param)) {
|
|
77
77
|
ref.__exec[param] = elementProp;
|
|
78
78
|
const execParam2 = elementProp = (0, import_utils.exec)(elementProp, element);
|
|
79
79
|
if (execParam2) {
|
|
@@ -297,6 +297,7 @@ const METHODS = [
|
|
|
297
297
|
"nextElement",
|
|
298
298
|
"previousElement"
|
|
299
299
|
];
|
|
300
|
-
const isMethod = function(param) {
|
|
301
|
-
|
|
300
|
+
const isMethod = function(param, element) {
|
|
301
|
+
var _a, _b;
|
|
302
|
+
return METHODS.includes(param) || ((_b = (_a = element == null ? void 0 : element.context) == null ? void 0 : _a.methods) == null ? void 0 : _b[param]);
|
|
302
303
|
};
|
package/dist/cjs/methods/set.js
CHANGED
|
@@ -57,6 +57,8 @@ const addMethods = (element, parent) => {
|
|
|
57
57
|
nextElement: import__.nextElement.bind(element),
|
|
58
58
|
previousElement: import__.previousElement.bind(element)
|
|
59
59
|
};
|
|
60
|
+
if (element.context.methods)
|
|
61
|
+
(0, import_utils.merge)(proto, element.context.methods);
|
|
60
62
|
if ((0, import_utils.isDevelopment)())
|
|
61
63
|
proto.log = import__.log.bind(element);
|
|
62
64
|
Object.setPrototypeOf(element, proto);
|
package/dist/cjs/node.js
CHANGED
|
@@ -73,7 +73,7 @@ const createNode = (element, options) => {
|
|
|
73
73
|
const value = element[param];
|
|
74
74
|
if (!Object.hasOwnProperty.call(element, param))
|
|
75
75
|
continue;
|
|
76
|
-
if ((0, import_utils.isUndefined)(value) || (0, import_methods.isMethod)(param) || (0, import_utils.isVariant)(param) || (0, import_utils.isObject)(import_mixins.registry[param]))
|
|
76
|
+
if ((0, import_utils.isUndefined)(value) || (0, import_methods.isMethod)(param, element) || (0, import_utils.isVariant)(param) || (0, import_utils.isObject)(import_mixins.registry[param]))
|
|
77
77
|
continue;
|
|
78
78
|
const isElement = (0, import_applyParam.applyParam)(param, element, options);
|
|
79
79
|
if (isElement) {
|
package/dist/cjs/update.js
CHANGED
|
@@ -136,7 +136,7 @@ const update = function(params = {}, opts) {
|
|
|
136
136
|
const isInPreventUpdate = (0, import_utils.isArray)(preventUpdate) && preventUpdate.includes(param);
|
|
137
137
|
const isInPreventDefineUpdate = (0, import_utils.isArray)(preventDefineUpdate) && preventDefineUpdate.includes(param);
|
|
138
138
|
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
|
|
139
|
-
if ((0, import_utils.isUndefined)(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || (0, import_methods.isMethod)(param) || (0, import_utils.isObject)(import_mixins.registry[param]) || (0, import_utils.isVariant)(param))
|
|
139
|
+
if ((0, import_utils.isUndefined)(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || (0, import_methods.isMethod)(param, element) || (0, import_utils.isObject)(import_mixins.registry[param]) || (0, import_utils.isVariant)(param))
|
|
140
140
|
continue;
|
|
141
141
|
if (preventStateUpdate === "once")
|
|
142
142
|
options.preventStateUpdate = false;
|
|
@@ -174,11 +174,11 @@ const captureSnapshot = (element, options) => {
|
|
|
174
174
|
return [snapshotOnCallee, calleeElement];
|
|
175
175
|
};
|
|
176
176
|
const checkIfOnUpdate = (element, parent, options) => {
|
|
177
|
-
var _a, _b;
|
|
178
|
-
if (!(0, import_utils.isFunction)(element.if) && !(0, import_utils.isFunction)(element.props.if) || !parent)
|
|
177
|
+
var _a, _b, _c;
|
|
178
|
+
if (!(0, import_utils.isFunction)(element.if) && !(0, import_utils.isFunction)((_a = element.props) == null ? void 0 : _a.if) || !parent)
|
|
179
179
|
return;
|
|
180
180
|
const ref = element.__ref;
|
|
181
|
-
const ifPassed = (element.if || ((
|
|
181
|
+
const ifPassed = (element.if || ((_b = element.props) == null ? void 0 : _b.if))(element, element.state, element.context, options);
|
|
182
182
|
const itWasFalse = ref.__if !== true;
|
|
183
183
|
if (ifPassed) {
|
|
184
184
|
ref.__if = true;
|
|
@@ -201,7 +201,7 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
201
201
|
const contentKey = ref.contentElementKey;
|
|
202
202
|
if (element.$collection || element.$stateCollection || element.$propsCollection) {
|
|
203
203
|
element.removeContent();
|
|
204
|
-
} else if ((
|
|
204
|
+
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep)
|
|
205
205
|
element[contentKey] = element[contentKey].parseDeep();
|
|
206
206
|
const previousElement = element.previousElement();
|
|
207
207
|
const previousNode = previousElement == null ? void 0 : previousElement.node;
|
|
@@ -30,6 +30,7 @@ const replaceOnKeys = (key) => key.replace(/on\w+/g, (match) => match.substring(
|
|
|
30
30
|
const createValidDomqlObjectFromSugar = (el, parent, key, options) => {
|
|
31
31
|
const newElem = {
|
|
32
32
|
props: {},
|
|
33
|
+
define: {},
|
|
33
34
|
on: {}
|
|
34
35
|
};
|
|
35
36
|
for (const k in el) {
|
|
@@ -39,6 +40,10 @@ const createValidDomqlObjectFromSugar = (el, parent, key, options) => {
|
|
|
39
40
|
const onKey = replaceOnKeys(prop);
|
|
40
41
|
newElem.on[onKey] = prop;
|
|
41
42
|
}
|
|
43
|
+
const isDefine = k.startsWith("is") || k.startsWith("has") || k.startsWith("use");
|
|
44
|
+
if (isDefine) {
|
|
45
|
+
newElem.define[k] = prop;
|
|
46
|
+
}
|
|
42
47
|
const isComponent = (0, import_utils.checkIfKeyIsComponent)(k);
|
|
43
48
|
const isRegistry = import_mixins.registry[k];
|
|
44
49
|
if (isComponent || isRegistry) {
|
|
@@ -74,7 +74,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
74
74
|
(0, import_iterate.throughInitialExec)(element);
|
|
75
75
|
for (const param in element) {
|
|
76
76
|
const prop = element[param];
|
|
77
|
-
if ((0, import_utils.isUndefined)(prop) || (0, import_methods.isMethod)(param) || (0, import_utils.isObject)(import_mixins.registry[param]) || (0, import__2.isVariant)(param))
|
|
77
|
+
if ((0, import_utils.isUndefined)(prop) || (0, import_methods.isMethod)(param, element) || (0, import_utils.isObject)(import_mixins.registry[param]) || (0, import__2.isVariant)(param))
|
|
78
78
|
continue;
|
|
79
79
|
const hasDefine = element.define && element.define[param];
|
|
80
80
|
const contextHasDefine = element.context && element.context.define && element.context.define[param];
|
package/extend.js
CHANGED
|
@@ -63,22 +63,20 @@ export const applyExtend = (element, parent, options = {}) => {
|
|
|
63
63
|
stack = extendStack
|
|
64
64
|
} else if (childExtendLength) {
|
|
65
65
|
stack = childExtendStack
|
|
66
|
-
} else if (!
|
|
66
|
+
} else if (!context.defaultExtends) return element
|
|
67
67
|
|
|
68
|
-
if (
|
|
68
|
+
if (context.defaultExtends) {
|
|
69
69
|
if (!mainExtend) {
|
|
70
|
-
const defaultOptionsExtend = getExtendStack(
|
|
70
|
+
const defaultOptionsExtend = getExtendStack(context.defaultExtends, context)
|
|
71
71
|
mainExtend = cloneAndMergeArrayExtend(defaultOptionsExtend)
|
|
72
72
|
delete mainExtend.extend
|
|
73
73
|
}
|
|
74
74
|
stack = [].concat(stack, mainExtend)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
// check if array contains string extends
|
|
78
77
|
if (__ref) __ref.__extend = stack
|
|
79
78
|
let mergedExtend = cloneAndMergeArrayExtend(stack)
|
|
80
79
|
|
|
81
|
-
// apply `component:` property
|
|
82
80
|
const COMPONENTS = (context && context.components) || options.components
|
|
83
81
|
const component = exec(element.component || mergedExtend.component, element)
|
|
84
82
|
if (component && COMPONENTS && COMPONENTS[component]) {
|
package/iterate.js
CHANGED
|
@@ -19,7 +19,7 @@ export const throughInitialExec = (element, exclude = {}) => {
|
|
|
19
19
|
for (const param in element) {
|
|
20
20
|
if (exclude[param]) continue
|
|
21
21
|
const prop = element[param]
|
|
22
|
-
if (isFunction(prop) && !isMethod(param) && !isVariant(param)) {
|
|
22
|
+
if (isFunction(prop) && !isMethod(param, element) && !isVariant(param)) {
|
|
23
23
|
ref.__exec[param] = prop
|
|
24
24
|
element[param] = prop(element, element.state, element.context)
|
|
25
25
|
// if (isComponent)
|
|
@@ -69,7 +69,7 @@ export const throughInitialDefine = (element) => {
|
|
|
69
69
|
for (const param in defineObj) {
|
|
70
70
|
let elementProp = element[param]
|
|
71
71
|
|
|
72
|
-
if (isFunction(elementProp) && !isMethod(param) && !isVariant(param)) {
|
|
72
|
+
if (isFunction(elementProp) && !isMethod(param, element) && !isVariant(param)) {
|
|
73
73
|
ref.__exec[param] = elementProp
|
|
74
74
|
const execParam = elementProp = exec(elementProp, element)
|
|
75
75
|
|
package/methods/index.js
CHANGED
|
@@ -267,6 +267,6 @@ export const METHODS = [
|
|
|
267
267
|
'previousElement'
|
|
268
268
|
]
|
|
269
269
|
|
|
270
|
-
export const isMethod = function (param) {
|
|
271
|
-
return METHODS.includes(param)
|
|
270
|
+
export const isMethod = function (param, element) {
|
|
271
|
+
return METHODS.includes(param) || element?.context?.methods?.[param]
|
|
272
272
|
}
|
package/methods/set.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isDevelopment } from '@domql/utils'
|
|
3
|
+
import { isDevelopment, merge } from '@domql/utils'
|
|
4
4
|
|
|
5
5
|
import set, { reset } from '../set'
|
|
6
6
|
import update from '../update'
|
|
@@ -45,6 +45,7 @@ export const addMethods = (element, parent) => {
|
|
|
45
45
|
nextElement: nextElement.bind(element),
|
|
46
46
|
previousElement: previousElement.bind(element)
|
|
47
47
|
}
|
|
48
|
+
if (element.context.methods) merge(proto, element.context.methods)
|
|
48
49
|
if (isDevelopment()) proto.log = log.bind(element)
|
|
49
50
|
Object.setPrototypeOf(element, proto)
|
|
50
51
|
}
|
package/node.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.142",
|
|
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.142",
|
|
30
|
+
"@domql/render": "^2.5.142",
|
|
31
|
+
"@domql/state": "^2.5.142",
|
|
32
|
+
"@domql/utils": "^2.5.142"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "65537c9b9a818948e1835b75a5c8a3e79bffdecd",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|
package/update.js
CHANGED
|
@@ -133,7 +133,7 @@ const update = function (params = {}, opts) {
|
|
|
133
133
|
preventDefineUpdate === param ||
|
|
134
134
|
(preventContentUpdate && param === 'content' && !hasCollection) ||
|
|
135
135
|
(preventStateUpdate && param) === 'state' ||
|
|
136
|
-
isMethod(param) || isObject(registry[param]) || isVariant(param)
|
|
136
|
+
isMethod(param, element) || isObject(registry[param]) || isVariant(param)
|
|
137
137
|
) continue
|
|
138
138
|
|
|
139
139
|
if (preventStateUpdate === 'once') options.preventStateUpdate = false
|
|
@@ -180,7 +180,7 @@ const captureSnapshot = (element, options) => {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
const checkIfOnUpdate = (element, parent, options) => {
|
|
183
|
-
if ((!isFunction(element.if) && !isFunction(element.props
|
|
183
|
+
if ((!isFunction(element.if) && !isFunction(element.props?.if)) || !parent) return
|
|
184
184
|
|
|
185
185
|
const ref = element.__ref
|
|
186
186
|
const ifPassed = (element.if || element.props?.if)(element, element.state, element.context, options)
|
package/utils/component.js
CHANGED
|
@@ -18,6 +18,7 @@ const replaceOnKeys = key => key.replace(/on\w+/g, match => match.substring(2))
|
|
|
18
18
|
export const createValidDomqlObjectFromSugar = (el, parent, key, options) => {
|
|
19
19
|
const newElem = {
|
|
20
20
|
props: {},
|
|
21
|
+
define: {},
|
|
21
22
|
on: {}
|
|
22
23
|
}
|
|
23
24
|
for (const k in el) {
|
|
@@ -29,6 +30,12 @@ export const createValidDomqlObjectFromSugar = (el, parent, key, options) => {
|
|
|
29
30
|
// } else if (!isMethod && checkIfKeyIsProperty(k)) {
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
const isDefine = k.startsWith('is') || k.startsWith('has') || k.startsWith('use')
|
|
34
|
+
if (isDefine) {
|
|
35
|
+
newElem.define[k] = prop
|
|
36
|
+
// } else if (!isMethod && checkIfKeyIsProperty(k)) {
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
const isComponent = checkIfKeyIsComponent(k)
|
|
33
40
|
const isRegistry = registry[k]
|
|
34
41
|
if (isComponent || isRegistry) {
|