@domql/element 2.5.65 → 2.5.66
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/update.js +26 -7
- package/package.json +2 -2
- package/update.js +22 -10
package/dist/cjs/update.js
CHANGED
|
@@ -105,20 +105,39 @@ const update = function(params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
105
105
|
if (!node) {
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
+
const {
|
|
109
|
+
onlyUpdate,
|
|
110
|
+
preventUpdate,
|
|
111
|
+
preventDefineUpdate,
|
|
112
|
+
preventContentUpdate,
|
|
113
|
+
preventStateUpdate,
|
|
114
|
+
preventRecursive,
|
|
115
|
+
preventUpdateListener,
|
|
116
|
+
preventUpdateAfter,
|
|
117
|
+
preventUpdateAfterCount
|
|
118
|
+
} = options;
|
|
119
|
+
if (preventUpdateAfter) {
|
|
120
|
+
if ((0, import_utils.isNumber)(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount)
|
|
121
|
+
return;
|
|
122
|
+
else if (options.preventUpdateAfterCount === void 0)
|
|
123
|
+
options.preventUpdateAfterCount = 1;
|
|
124
|
+
else
|
|
125
|
+
options.preventUpdateAfterCount++;
|
|
126
|
+
}
|
|
108
127
|
for (const param in element) {
|
|
109
128
|
const prop = element[param];
|
|
110
|
-
const hasOnlyUpdateFalsy =
|
|
111
|
-
const isInPreventUpdate = (0, import_utils.isArray)(
|
|
112
|
-
const isInPreventDefineUpdate = (0, import_utils.isArray)(
|
|
129
|
+
const hasOnlyUpdateFalsy = onlyUpdate && (onlyUpdate !== param || !element.lookup(onlyUpdate));
|
|
130
|
+
const isInPreventUpdate = (0, import_utils.isArray)(preventUpdate) && preventUpdate.includes(param);
|
|
131
|
+
const isInPreventDefineUpdate = (0, import_utils.isArray)(preventDefineUpdate) && preventDefineUpdate.includes(param);
|
|
113
132
|
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
|
|
114
|
-
if ((0, import_utils.isUndefined)(prop) || hasOnlyUpdateFalsy || isInPreventUpdate || isInPreventDefineUpdate ||
|
|
133
|
+
if ((0, import_utils.isUndefined)(prop) || hasOnlyUpdateFalsy || 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_utils2.isVariant)(param))
|
|
115
134
|
continue;
|
|
116
|
-
if (
|
|
135
|
+
if (preventStateUpdate === "once")
|
|
117
136
|
options.preventStateUpdate = false;
|
|
118
137
|
const isElement = (0, import_applyParam.applyParam)(param, element, options);
|
|
119
138
|
if (isElement) {
|
|
120
139
|
const { hasDefine, hasContextDefine } = isElement;
|
|
121
|
-
const canUpdate = (0, import_utils.isObject)(prop) && !hasDefine && !hasContextDefine && !
|
|
140
|
+
const canUpdate = (0, import_utils.isObject)(prop) && !hasDefine && !hasContextDefine && !preventRecursive;
|
|
122
141
|
if (!canUpdate)
|
|
123
142
|
continue;
|
|
124
143
|
const lazyLoad = element.props.lazyLoad || options.lazyLoad;
|
|
@@ -130,7 +149,7 @@ const update = function(params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
130
149
|
lazyLoad ? import_utils.window.requestAnimationFrame(() => childUpdateCall()) : childUpdateCall();
|
|
131
150
|
}
|
|
132
151
|
}
|
|
133
|
-
if (!
|
|
152
|
+
if (!preventUpdateListener)
|
|
134
153
|
(0, import_event.triggerEventOn)("update", element, options);
|
|
135
154
|
};
|
|
136
155
|
const captureSnapshot = (element, options) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.66",
|
|
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": "5cb5b9bd779042cc3cfe3d912bdc48fb8293ea0b",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|
package/update.js
CHANGED
|
@@ -97,11 +97,23 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
97
97
|
return
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
const {
|
|
101
|
+
onlyUpdate, preventUpdate, preventDefineUpdate, preventContentUpdate, preventStateUpdate,
|
|
102
|
+
preventRecursive, preventUpdateListener, preventUpdateAfter, preventUpdateAfterCount
|
|
103
|
+
} = options
|
|
104
|
+
|
|
105
|
+
if (preventUpdateAfter) {
|
|
106
|
+
if (isNumber(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount) return
|
|
107
|
+
else if (options.preventUpdateAfterCount === undefined) options.preventUpdateAfterCount = 1
|
|
108
|
+
else options.preventUpdateAfterCount++
|
|
109
|
+
}
|
|
110
|
+
|
|
100
111
|
for (const param in element) {
|
|
101
112
|
const prop = element[param]
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
const
|
|
113
|
+
|
|
114
|
+
const hasOnlyUpdateFalsy = onlyUpdate && (onlyUpdate !== param || !element.lookup(onlyUpdate))
|
|
115
|
+
const isInPreventUpdate = isArray(preventUpdate) && preventUpdate.includes(param)
|
|
116
|
+
const isInPreventDefineUpdate = isArray(preventDefineUpdate) && preventDefineUpdate.includes(param)
|
|
105
117
|
|
|
106
118
|
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection
|
|
107
119
|
|
|
@@ -110,18 +122,18 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
110
122
|
hasOnlyUpdateFalsy ||
|
|
111
123
|
isInPreventUpdate ||
|
|
112
124
|
isInPreventDefineUpdate ||
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
(
|
|
116
|
-
(
|
|
125
|
+
preventDefineUpdate === true ||
|
|
126
|
+
preventDefineUpdate === param ||
|
|
127
|
+
(preventContentUpdate && param === 'content' && !hasCollection) ||
|
|
128
|
+
(preventStateUpdate && param) === 'state' ||
|
|
117
129
|
isMethod(param) || isObject(registry[param]) || isVariant(param)
|
|
118
130
|
) continue
|
|
119
|
-
if (
|
|
131
|
+
if (preventStateUpdate === 'once') options.preventStateUpdate = false
|
|
120
132
|
|
|
121
133
|
const isElement = applyParam(param, element, options)
|
|
122
134
|
if (isElement) {
|
|
123
135
|
const { hasDefine, hasContextDefine } = isElement
|
|
124
|
-
const canUpdate = isObject(prop) && !hasDefine && !hasContextDefine && !
|
|
136
|
+
const canUpdate = isObject(prop) && !hasDefine && !hasContextDefine && !preventRecursive
|
|
125
137
|
if (!canUpdate) continue
|
|
126
138
|
|
|
127
139
|
const lazyLoad = element.props.lazyLoad || options.lazyLoad
|
|
@@ -136,7 +148,7 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
136
148
|
}
|
|
137
149
|
}
|
|
138
150
|
|
|
139
|
-
if (!
|
|
151
|
+
if (!preventUpdateListener) triggerEventOn('update', element, options)
|
|
140
152
|
}
|
|
141
153
|
|
|
142
154
|
const captureSnapshot = (element, options) => {
|