@domql/utils 3.0.7 → 3.1.2
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/env.js +15 -4
- package/dist/cjs/events.js +6 -6
- package/dist/cjs/extends.js +1 -1
- package/dist/cjs/props.js +26 -21
- package/dist/esm/env.js +15 -4
- package/dist/esm/events.js +6 -6
- package/dist/esm/extends.js +1 -1
- package/dist/esm/props.js +26 -21
- package/env.js +9 -7
- package/events.js +5 -5
- package/extends.js +1 -1
- package/package.json +4 -4
- package/props.js +29 -23
package/dist/cjs/env.js
CHANGED
|
@@ -18,15 +18,26 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var env_exports = {};
|
|
20
20
|
__export(env_exports, {
|
|
21
|
+
ENV: () => ENV,
|
|
21
22
|
NODE_ENV: () => NODE_ENV,
|
|
22
23
|
getNev: () => getNev,
|
|
23
24
|
isDevelopment: () => isDevelopment,
|
|
25
|
+
isLocal: () => isLocal,
|
|
26
|
+
isNotProduction: () => isNotProduction,
|
|
24
27
|
isProduction: () => isProduction,
|
|
25
|
-
|
|
28
|
+
isStaging: () => isStaging,
|
|
29
|
+
isTest: () => isTest,
|
|
30
|
+
isTesting: () => isTesting
|
|
26
31
|
});
|
|
27
32
|
module.exports = __toCommonJS(env_exports);
|
|
33
|
+
// @preserve-env
|
|
28
34
|
const NODE_ENV = "development";
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
35
|
+
const ENV = NODE_ENV;
|
|
36
|
+
const isProduction = (env = NODE_ENV) => env === "production";
|
|
37
|
+
const isTest = (env = NODE_ENV) => env === "testing" || env === "test";
|
|
38
|
+
const isTesting = isTest;
|
|
39
|
+
const isStaging = (env = NODE_ENV) => env === "staging";
|
|
40
|
+
const isLocal = (env = NODE_ENV) => env === "local";
|
|
41
|
+
const isDevelopment = (env = NODE_ENV) => env === "development" || env === "dev" || env === "local";
|
|
32
42
|
const getNev = (key, env = NODE_ENV) => env[key];
|
|
43
|
+
const isNotProduction = (env = NODE_ENV) => !isProduction(env);
|
package/dist/cjs/events.js
CHANGED
|
@@ -23,15 +23,15 @@ __export(events_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(events_exports);
|
|
24
24
|
var import_string = require("./string.js");
|
|
25
25
|
var import_types = require("./types.js");
|
|
26
|
-
|
|
27
|
-
const { props, on } =
|
|
26
|
+
function addEventFromProps(key, obj) {
|
|
27
|
+
const { props, on } = obj;
|
|
28
28
|
const eventName = (0, import_string.lowercaseFirstLetter)(key.split("on")[1]);
|
|
29
29
|
const origEvent = on[eventName];
|
|
30
30
|
const funcFromProps = props[key];
|
|
31
31
|
if ((0, import_types.isFunction)(origEvent)) {
|
|
32
|
-
on[eventName] = (...args) => {
|
|
33
|
-
const originalEventRetunrs = origEvent(...args);
|
|
34
|
-
if (originalEventRetunrs !== false) funcFromProps(...args);
|
|
32
|
+
on[eventName] = async (...args) => {
|
|
33
|
+
const originalEventRetunrs = await origEvent(...args);
|
|
34
|
+
if (originalEventRetunrs !== false) await funcFromProps(...args);
|
|
35
35
|
};
|
|
36
36
|
} else on[eventName] = funcFromProps;
|
|
37
|
-
}
|
|
37
|
+
}
|
package/dist/cjs/extends.js
CHANGED
|
@@ -97,7 +97,7 @@ const addExtends = (newExtends, element) => {
|
|
|
97
97
|
};
|
|
98
98
|
const concatAddExtends = (newExtend, element) => {
|
|
99
99
|
if (!newExtend) return element;
|
|
100
|
-
const {
|
|
100
|
+
const { extends: elementExtend } = element;
|
|
101
101
|
const originalArray = (0, import_types.isArray)(elementExtend) ? elementExtend : [elementExtend];
|
|
102
102
|
const receivedArray = (0, import_types.isArray)(newExtend) ? newExtend : [newExtend];
|
|
103
103
|
return {
|
package/dist/cjs/props.js
CHANGED
|
@@ -28,6 +28,7 @@ __export(props_exports, {
|
|
|
28
28
|
pickupPropsFromElement: () => pickupPropsFromElement,
|
|
29
29
|
propExists: () => propExists,
|
|
30
30
|
propertizeElement: () => propertizeElement,
|
|
31
|
+
propertizeUpdate: () => propertizeUpdate,
|
|
31
32
|
removeDuplicateProps: () => removeDuplicateProps,
|
|
32
33
|
setPropsPrototype: () => setPropsPrototype,
|
|
33
34
|
syncProps: () => syncProps,
|
|
@@ -50,53 +51,57 @@ const createProps = (element, parent, key) => {
|
|
|
50
51
|
}
|
|
51
52
|
return { ...props };
|
|
52
53
|
};
|
|
53
|
-
function pickupPropsFromElement(
|
|
54
|
+
function pickupPropsFromElement(obj, opts = {}) {
|
|
54
55
|
var _a, _b, _c;
|
|
55
56
|
const cachedKeys = opts.cachedKeys || [];
|
|
56
|
-
for (const key in
|
|
57
|
-
const value =
|
|
58
|
-
const hasDefine = (0, import_types.isObject)((_a =
|
|
59
|
-
const hasGlobalDefine = (0, import_types.isObject)((_c = (_b =
|
|
57
|
+
for (const key in obj) {
|
|
58
|
+
const value = obj[key];
|
|
59
|
+
const hasDefine = (0, import_types.isObject)((_a = this.define) == null ? void 0 : _a[key]);
|
|
60
|
+
const hasGlobalDefine = (0, import_types.isObject)((_c = (_b = this.context) == null ? void 0 : _b.define) == null ? void 0 : _c[key]);
|
|
60
61
|
const isElement = /^[A-Z]/.test(key) || /^\d+$/.test(key);
|
|
61
62
|
const isBuiltin = import_keys.DOMQ_PROPERTIES.includes(key);
|
|
62
63
|
if (!isElement && !isBuiltin && !hasDefine && !hasGlobalDefine) {
|
|
63
|
-
|
|
64
|
-
delete
|
|
64
|
+
obj.props[key] = value;
|
|
65
|
+
delete obj[key];
|
|
65
66
|
cachedKeys.push(key);
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
|
-
return
|
|
69
|
+
return obj;
|
|
69
70
|
}
|
|
70
|
-
function pickupElementFromProps(
|
|
71
|
+
function pickupElementFromProps(obj = this, opts) {
|
|
71
72
|
var _a, _b, _c;
|
|
72
73
|
const cachedKeys = opts.cachedKeys || [];
|
|
73
|
-
for (const key in
|
|
74
|
-
const value =
|
|
74
|
+
for (const key in obj.props) {
|
|
75
|
+
const value = obj.props[key];
|
|
75
76
|
const isEvent = key.startsWith("on") && key.length > 2;
|
|
76
77
|
const isFn = (0, import_types.isFunction)(value);
|
|
77
78
|
if (isEvent && isFn) {
|
|
78
|
-
(0, import_events.addEventFromProps)(key,
|
|
79
|
-
delete
|
|
79
|
+
(0, import_events.addEventFromProps)(key, obj);
|
|
80
|
+
delete obj.props[key];
|
|
80
81
|
continue;
|
|
81
82
|
}
|
|
82
83
|
if (cachedKeys.includes(key)) continue;
|
|
83
|
-
const hasDefine = (0, import_types.isObject)((_a =
|
|
84
|
-
const hasGlobalDefine = (0, import_types.isObject)((_c = (_b =
|
|
84
|
+
const hasDefine = (0, import_types.isObject)((_a = this.define) == null ? void 0 : _a[key]);
|
|
85
|
+
const hasGlobalDefine = (0, import_types.isObject)((_c = (_b = this.context) == null ? void 0 : _b.define) == null ? void 0 : _c[key]);
|
|
85
86
|
const isElement = /^[A-Z]/.test(key) || /^\d+$/.test(key);
|
|
86
87
|
const isBuiltin = import_keys.DOMQ_PROPERTIES.includes(key);
|
|
87
88
|
if (isElement || isBuiltin || hasDefine || hasGlobalDefine) {
|
|
88
|
-
|
|
89
|
-
delete
|
|
89
|
+
obj[key] = value;
|
|
90
|
+
if (obj.props) delete obj.props[key];
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
|
-
return
|
|
93
|
+
return obj;
|
|
93
94
|
}
|
|
94
|
-
function propertizeElement(element
|
|
95
|
+
function propertizeElement(element = this) {
|
|
95
96
|
const cachedKeys = [];
|
|
96
|
-
pickupPropsFromElement(element, { cachedKeys });
|
|
97
|
-
pickupElementFromProps(element, { cachedKeys });
|
|
97
|
+
pickupPropsFromElement.call(this, element, { cachedKeys });
|
|
98
|
+
pickupElementFromProps.call(this, element, { cachedKeys });
|
|
98
99
|
return element;
|
|
99
100
|
}
|
|
101
|
+
function propertizeUpdate(params = {}) {
|
|
102
|
+
const obj = (0, import_object.deepMerge)({ on: {}, props: {} }, params);
|
|
103
|
+
return propertizeElement.call(this, obj);
|
|
104
|
+
}
|
|
100
105
|
const objectizeStringProperty = (propValue) => {
|
|
101
106
|
if ((0, import_types.is)(propValue)("string", "number")) {
|
|
102
107
|
return { inheritedString: propValue };
|
package/dist/esm/env.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
+
// @preserve-env
|
|
1
2
|
const NODE_ENV = "development";
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const ENV = NODE_ENV;
|
|
4
|
+
const isProduction = (env = NODE_ENV) => env === "production";
|
|
5
|
+
const isTest = (env = NODE_ENV) => env === "testing" || env === "test";
|
|
6
|
+
const isTesting = isTest;
|
|
7
|
+
const isStaging = (env = NODE_ENV) => env === "staging";
|
|
8
|
+
const isLocal = (env = NODE_ENV) => env === "local";
|
|
9
|
+
const isDevelopment = (env = NODE_ENV) => env === "development" || env === "dev" || env === "local";
|
|
5
10
|
const getNev = (key, env = NODE_ENV) => env[key];
|
|
11
|
+
const isNotProduction = (env = NODE_ENV) => !isProduction(env);
|
|
6
12
|
export {
|
|
13
|
+
ENV,
|
|
7
14
|
NODE_ENV,
|
|
8
15
|
getNev,
|
|
9
16
|
isDevelopment,
|
|
17
|
+
isLocal,
|
|
18
|
+
isNotProduction,
|
|
10
19
|
isProduction,
|
|
11
|
-
|
|
20
|
+
isStaging,
|
|
21
|
+
isTest,
|
|
22
|
+
isTesting
|
|
12
23
|
};
|
package/dist/esm/events.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { lowercaseFirstLetter } from "./string.js";
|
|
2
2
|
import { isFunction } from "./types.js";
|
|
3
|
-
|
|
4
|
-
const { props, on } =
|
|
3
|
+
function addEventFromProps(key, obj) {
|
|
4
|
+
const { props, on } = obj;
|
|
5
5
|
const eventName = lowercaseFirstLetter(key.split("on")[1]);
|
|
6
6
|
const origEvent = on[eventName];
|
|
7
7
|
const funcFromProps = props[key];
|
|
8
8
|
if (isFunction(origEvent)) {
|
|
9
|
-
on[eventName] = (...args) => {
|
|
10
|
-
const originalEventRetunrs = origEvent(...args);
|
|
11
|
-
if (originalEventRetunrs !== false) funcFromProps(...args);
|
|
9
|
+
on[eventName] = async (...args) => {
|
|
10
|
+
const originalEventRetunrs = await origEvent(...args);
|
|
11
|
+
if (originalEventRetunrs !== false) await funcFromProps(...args);
|
|
12
12
|
};
|
|
13
13
|
} else on[eventName] = funcFromProps;
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
15
|
export {
|
|
16
16
|
addEventFromProps
|
|
17
17
|
};
|
package/dist/esm/extends.js
CHANGED
|
@@ -67,7 +67,7 @@ const addExtends = (newExtends, element) => {
|
|
|
67
67
|
};
|
|
68
68
|
const concatAddExtends = (newExtend, element) => {
|
|
69
69
|
if (!newExtend) return element;
|
|
70
|
-
const {
|
|
70
|
+
const { extends: elementExtend } = element;
|
|
71
71
|
const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend];
|
|
72
72
|
const receivedArray = isArray(newExtend) ? newExtend : [newExtend];
|
|
73
73
|
return __spreadProps(__spreadValues({}, element), {
|
package/dist/esm/props.js
CHANGED
|
@@ -29,53 +29,57 @@ const createProps = (element, parent, key) => {
|
|
|
29
29
|
}
|
|
30
30
|
return __spreadValues({}, props);
|
|
31
31
|
};
|
|
32
|
-
function pickupPropsFromElement(
|
|
32
|
+
function pickupPropsFromElement(obj, opts = {}) {
|
|
33
33
|
var _a, _b, _c;
|
|
34
34
|
const cachedKeys = opts.cachedKeys || [];
|
|
35
|
-
for (const key in
|
|
36
|
-
const value =
|
|
37
|
-
const hasDefine = isObject((_a =
|
|
38
|
-
const hasGlobalDefine = isObject((_c = (_b =
|
|
35
|
+
for (const key in obj) {
|
|
36
|
+
const value = obj[key];
|
|
37
|
+
const hasDefine = isObject((_a = this.define) == null ? void 0 : _a[key]);
|
|
38
|
+
const hasGlobalDefine = isObject((_c = (_b = this.context) == null ? void 0 : _b.define) == null ? void 0 : _c[key]);
|
|
39
39
|
const isElement = /^[A-Z]/.test(key) || /^\d+$/.test(key);
|
|
40
40
|
const isBuiltin = DOMQ_PROPERTIES.includes(key);
|
|
41
41
|
if (!isElement && !isBuiltin && !hasDefine && !hasGlobalDefine) {
|
|
42
|
-
|
|
43
|
-
delete
|
|
42
|
+
obj.props[key] = value;
|
|
43
|
+
delete obj[key];
|
|
44
44
|
cachedKeys.push(key);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
return
|
|
47
|
+
return obj;
|
|
48
48
|
}
|
|
49
|
-
function pickupElementFromProps(
|
|
49
|
+
function pickupElementFromProps(obj = this, opts) {
|
|
50
50
|
var _a, _b, _c;
|
|
51
51
|
const cachedKeys = opts.cachedKeys || [];
|
|
52
|
-
for (const key in
|
|
53
|
-
const value =
|
|
52
|
+
for (const key in obj.props) {
|
|
53
|
+
const value = obj.props[key];
|
|
54
54
|
const isEvent = key.startsWith("on") && key.length > 2;
|
|
55
55
|
const isFn = isFunction(value);
|
|
56
56
|
if (isEvent && isFn) {
|
|
57
|
-
addEventFromProps(key,
|
|
58
|
-
delete
|
|
57
|
+
addEventFromProps(key, obj);
|
|
58
|
+
delete obj.props[key];
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
61
|
if (cachedKeys.includes(key)) continue;
|
|
62
|
-
const hasDefine = isObject((_a =
|
|
63
|
-
const hasGlobalDefine = isObject((_c = (_b =
|
|
62
|
+
const hasDefine = isObject((_a = this.define) == null ? void 0 : _a[key]);
|
|
63
|
+
const hasGlobalDefine = isObject((_c = (_b = this.context) == null ? void 0 : _b.define) == null ? void 0 : _c[key]);
|
|
64
64
|
const isElement = /^[A-Z]/.test(key) || /^\d+$/.test(key);
|
|
65
65
|
const isBuiltin = DOMQ_PROPERTIES.includes(key);
|
|
66
66
|
if (isElement || isBuiltin || hasDefine || hasGlobalDefine) {
|
|
67
|
-
|
|
68
|
-
delete
|
|
67
|
+
obj[key] = value;
|
|
68
|
+
if (obj.props) delete obj.props[key];
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
return
|
|
71
|
+
return obj;
|
|
72
72
|
}
|
|
73
|
-
function propertizeElement(element
|
|
73
|
+
function propertizeElement(element = this) {
|
|
74
74
|
const cachedKeys = [];
|
|
75
|
-
pickupPropsFromElement(element, { cachedKeys });
|
|
76
|
-
pickupElementFromProps(element, { cachedKeys });
|
|
75
|
+
pickupPropsFromElement.call(this, element, { cachedKeys });
|
|
76
|
+
pickupElementFromProps.call(this, element, { cachedKeys });
|
|
77
77
|
return element;
|
|
78
78
|
}
|
|
79
|
+
function propertizeUpdate(params = {}) {
|
|
80
|
+
const obj = deepMerge({ on: {}, props: {} }, params);
|
|
81
|
+
return propertizeElement.call(this, obj);
|
|
82
|
+
}
|
|
79
83
|
const objectizeStringProperty = (propValue) => {
|
|
80
84
|
if (is(propValue)("string", "number")) {
|
|
81
85
|
return { inheritedString: propValue };
|
|
@@ -208,6 +212,7 @@ export {
|
|
|
208
212
|
pickupPropsFromElement,
|
|
209
213
|
propExists,
|
|
210
214
|
propertizeElement,
|
|
215
|
+
propertizeUpdate,
|
|
211
216
|
removeDuplicateProps,
|
|
212
217
|
setPropsPrototype,
|
|
213
218
|
syncProps,
|
package/env.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
// @preserve-env
|
|
3
4
|
export const NODE_ENV = process.env.NODE_ENV
|
|
5
|
+
export const ENV = NODE_ENV
|
|
4
6
|
|
|
5
|
-
export const isProduction = (env = NODE_ENV) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export const
|
|
7
|
+
export const isProduction = (env = NODE_ENV) => env === 'production'
|
|
8
|
+
export const isTest = (env = NODE_ENV) => env === 'testing' || env === 'test'
|
|
9
|
+
export const isTesting = isTest
|
|
10
|
+
export const isStaging = (env = NODE_ENV) => env === 'staging'
|
|
11
|
+
export const isLocal = (env = NODE_ENV) => env === 'local'
|
|
10
12
|
export const isDevelopment = (env = NODE_ENV) =>
|
|
11
|
-
env === 'development' || env === 'dev'
|
|
12
|
-
|
|
13
|
+
env === 'development' || env === 'dev' || env === 'local'
|
|
13
14
|
export const getNev = (key, env = NODE_ENV) => env[key]
|
|
15
|
+
export const isNotProduction = (env = NODE_ENV) => !isProduction(env)
|
package/events.js
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
import { lowercaseFirstLetter } from './string.js'
|
|
4
4
|
import { isFunction } from './types.js'
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
const { props, on } =
|
|
6
|
+
export function addEventFromProps (key, obj) {
|
|
7
|
+
const { props, on } = obj
|
|
8
8
|
const eventName = lowercaseFirstLetter(key.split('on')[1])
|
|
9
9
|
const origEvent = on[eventName]
|
|
10
10
|
const funcFromProps = props[key]
|
|
11
11
|
if (isFunction(origEvent)) {
|
|
12
|
-
on[eventName] = (...args) => {
|
|
13
|
-
const originalEventRetunrs = origEvent(...args)
|
|
14
|
-
if (originalEventRetunrs !== false) funcFromProps(...args)
|
|
12
|
+
on[eventName] = async (...args) => {
|
|
13
|
+
const originalEventRetunrs = await origEvent(...args)
|
|
14
|
+
if (originalEventRetunrs !== false) await funcFromProps(...args)
|
|
15
15
|
}
|
|
16
16
|
} else on[eventName] = funcFromProps
|
|
17
17
|
}
|
package/extends.js
CHANGED
|
@@ -70,7 +70,7 @@ export const addExtends = (newExtends, element) => {
|
|
|
70
70
|
|
|
71
71
|
export const concatAddExtends = (newExtend, element) => {
|
|
72
72
|
if (!newExtend) return element
|
|
73
|
-
const {
|
|
73
|
+
const { extends: elementExtend } = element
|
|
74
74
|
const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend]
|
|
75
75
|
const receivedArray = isArray(newExtend) ? newExtend : [newExtend]
|
|
76
76
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
22
22
|
"build:esm": "npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
|
|
23
23
|
"build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
24
|
-
"build": "rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
24
|
+
"build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
25
25
|
"prepublish": "npm run build; npm run copy:package:cjs"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "429b36616aa04c8587a26ce3c129815115e35897",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@babel/core": "^7.
|
|
29
|
+
"@babel/core": "^7.26.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/props.js
CHANGED
|
@@ -18,70 +18,76 @@ export const createProps = (element, parent, key) => {
|
|
|
18
18
|
return { ...props }
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export function pickupPropsFromElement (
|
|
21
|
+
export function pickupPropsFromElement (obj, opts = {}) {
|
|
22
22
|
const cachedKeys = opts.cachedKeys || []
|
|
23
23
|
|
|
24
|
-
for (const key in
|
|
25
|
-
const value =
|
|
24
|
+
for (const key in obj) {
|
|
25
|
+
const value = obj[key]
|
|
26
26
|
|
|
27
|
-
const hasDefine = isObject(
|
|
28
|
-
const hasGlobalDefine = isObject(
|
|
27
|
+
const hasDefine = isObject(this.define?.[key])
|
|
28
|
+
const hasGlobalDefine = isObject(this.context?.define?.[key])
|
|
29
29
|
const isElement = /^[A-Z]/.test(key) || /^\d+$/.test(key)
|
|
30
30
|
const isBuiltin = DOMQ_PROPERTIES.includes(key)
|
|
31
31
|
|
|
32
32
|
// If it's not a special case, move to props
|
|
33
33
|
if (!isElement && !isBuiltin && !hasDefine && !hasGlobalDefine) {
|
|
34
|
-
|
|
35
|
-
delete
|
|
34
|
+
obj.props[key] = value
|
|
35
|
+
delete obj[key]
|
|
36
36
|
cachedKeys.push(key)
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
return
|
|
40
|
+
return obj
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export function pickupElementFromProps (
|
|
43
|
+
export function pickupElementFromProps (obj = this, opts) {
|
|
44
44
|
const cachedKeys = opts.cachedKeys || []
|
|
45
45
|
|
|
46
|
-
for (const key in
|
|
47
|
-
const value =
|
|
46
|
+
for (const key in obj.props) {
|
|
47
|
+
const value = obj.props[key]
|
|
48
48
|
|
|
49
49
|
// Handle event handlers
|
|
50
50
|
const isEvent = key.startsWith('on') && key.length > 2
|
|
51
51
|
const isFn = isFunction(value)
|
|
52
52
|
|
|
53
53
|
if (isEvent && isFn) {
|
|
54
|
-
addEventFromProps(key,
|
|
55
|
-
delete
|
|
54
|
+
addEventFromProps(key, obj)
|
|
55
|
+
delete obj.props[key]
|
|
56
56
|
continue
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
// Skip if key was originally from
|
|
59
|
+
// Skip if key was originally from obj
|
|
60
60
|
if (cachedKeys.includes(key)) continue
|
|
61
61
|
|
|
62
|
-
const hasDefine = isObject(
|
|
63
|
-
const hasGlobalDefine = isObject(
|
|
62
|
+
const hasDefine = isObject(this.define?.[key])
|
|
63
|
+
const hasGlobalDefine = isObject(this.context?.define?.[key])
|
|
64
64
|
const isElement = /^[A-Z]/.test(key) || /^\d+$/.test(key)
|
|
65
65
|
const isBuiltin = DOMQ_PROPERTIES.includes(key)
|
|
66
66
|
|
|
67
|
-
// Move qualifying properties back to
|
|
67
|
+
// Move qualifying properties back to obj root
|
|
68
68
|
if (isElement || isBuiltin || hasDefine || hasGlobalDefine) {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
obj[key] = value
|
|
70
|
+
|
|
71
|
+
if (obj.props) delete obj.props[key]
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
return
|
|
75
|
+
return obj
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
// Helper function to maintain compatibility with original propertizeElement
|
|
78
|
-
export function propertizeElement (element
|
|
79
|
+
export function propertizeElement (element = this) {
|
|
79
80
|
const cachedKeys = []
|
|
80
|
-
pickupPropsFromElement(element, { cachedKeys })
|
|
81
|
-
pickupElementFromProps(element, { cachedKeys })
|
|
81
|
+
pickupPropsFromElement.call(this, element, { cachedKeys })
|
|
82
|
+
pickupElementFromProps.call(this, element, { cachedKeys })
|
|
82
83
|
return element
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
export function propertizeUpdate (params = {}) {
|
|
87
|
+
const obj = deepMerge({ on: {}, props: {} }, params)
|
|
88
|
+
return propertizeElement.call(this, obj)
|
|
89
|
+
}
|
|
90
|
+
|
|
85
91
|
export const objectizeStringProperty = propValue => {
|
|
86
92
|
if (is(propValue)('string', 'number')) {
|
|
87
93
|
return { inheritedString: propValue }
|