@domql/element 2.5.29 → 2.5.31
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 +10 -4
- package/package.json +2 -2
- package/update.js +25 -5
package/dist/cjs/update.js
CHANGED
|
@@ -147,6 +147,7 @@ const captureSnapshot = (element, options) => {
|
|
|
147
147
|
return [snapshotOnCallee, calleeElement];
|
|
148
148
|
};
|
|
149
149
|
const checkIfOnUpdate = (element, parent, options) => {
|
|
150
|
+
var _a;
|
|
150
151
|
if (!(0, import_utils.isFunction)(element.if) || !parent)
|
|
151
152
|
return;
|
|
152
153
|
const ref = element.__ref;
|
|
@@ -163,16 +164,21 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
163
164
|
if (ref.__state) {
|
|
164
165
|
element.state = ref.__state;
|
|
165
166
|
}
|
|
167
|
+
(_a = element.node) == null ? void 0 : _a.remove();
|
|
166
168
|
const previousElement = element.previousElement();
|
|
167
169
|
const nextElement = element.nextElement();
|
|
168
170
|
const hasPrevious = previousElement && previousElement.node;
|
|
169
171
|
const hasNext = nextElement && nextElement.node;
|
|
170
|
-
const attachOptions = {
|
|
172
|
+
const attachOptions = ((hasPrevious == null ? void 0 : hasPrevious.parentNode) || (hasNext == null ? void 0 : hasNext.parentNode)) && {
|
|
171
173
|
position: hasPrevious ? "after" : hasNext ? "before" : null,
|
|
172
|
-
node: hasPrevious || hasNext
|
|
173
|
-
parentNode: parent.node
|
|
174
|
+
node: hasPrevious || hasNext
|
|
174
175
|
};
|
|
176
|
+
console.log(element);
|
|
177
|
+
console.log(attachOptions);
|
|
178
|
+
console.log(previousElement);
|
|
179
|
+
console.log(nextElement);
|
|
175
180
|
const created = (0, import_create.default)(element, parent, element.key, import_options.default.create, attachOptions);
|
|
181
|
+
console.log(created);
|
|
176
182
|
if (options.preventUpdate !== true && element.on && (0, import_utils.isFunction)(element.on.update)) {
|
|
177
183
|
(0, import_event.applyEvent)(element.on.update, created, created.state);
|
|
178
184
|
}
|
|
@@ -197,7 +203,7 @@ const inheritStateUpdates = (element, options) => {
|
|
|
197
203
|
const shouldForceFunctionState = (0, import_utils.isFunction)(stateKey) && !isHoisted && execStateFunction;
|
|
198
204
|
if (shouldForceFunctionState) {
|
|
199
205
|
const execState = (0, import_utils.exec)(stateKey, element);
|
|
200
|
-
state.set(execState, { ...options, preventUpdate: true });
|
|
206
|
+
state.set(execState, { ...options, preventUpdate: true, updatedByStateFunction: true });
|
|
201
207
|
return;
|
|
202
208
|
}
|
|
203
209
|
const keyInParentState = (0, import_state.findInheritedState)(element, element.parent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.31",
|
|
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": "9407d22e1bbce8be17bd6b5b86eba8a2358ddeb9",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|
package/update.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
window,
|
|
5
|
+
exec,
|
|
6
|
+
isArray,
|
|
7
|
+
isFunction,
|
|
8
|
+
isNumber,
|
|
9
|
+
isObject,
|
|
10
|
+
isString,
|
|
11
|
+
isUndefined,
|
|
12
|
+
merge,
|
|
13
|
+
overwriteDeep,
|
|
14
|
+
createSnapshotId
|
|
15
|
+
} from '@domql/utils'
|
|
16
|
+
|
|
4
17
|
import { applyEvent, triggerEventOn, triggerEventOnUpdate } from '@domql/event'
|
|
5
18
|
import { isMethod } from './methods'
|
|
6
19
|
import { updateProps } from './props'
|
|
@@ -161,19 +174,26 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
161
174
|
element.state = ref.__state
|
|
162
175
|
}
|
|
163
176
|
|
|
177
|
+
element.node?.remove()
|
|
178
|
+
|
|
164
179
|
const previousElement = element.previousElement()
|
|
165
180
|
const nextElement = element.nextElement()
|
|
166
181
|
|
|
167
182
|
const hasPrevious = previousElement && previousElement.node
|
|
168
183
|
const hasNext = nextElement && nextElement.node
|
|
169
184
|
|
|
170
|
-
const attachOptions = {
|
|
185
|
+
const attachOptions = (hasPrevious?.parentNode || hasNext?.parentNode) && {
|
|
171
186
|
position: hasPrevious ? 'after' : hasNext ? 'before' : null,
|
|
172
|
-
node: hasPrevious || hasNext
|
|
173
|
-
parentNode: parent.node
|
|
187
|
+
node: hasPrevious || hasNext
|
|
174
188
|
}
|
|
175
189
|
|
|
190
|
+
console.log(element)
|
|
191
|
+
console.log(attachOptions)
|
|
192
|
+
console.log(previousElement)
|
|
193
|
+
console.log(nextElement)
|
|
194
|
+
|
|
176
195
|
const created = create(element, parent, element.key, OPTIONS.create, attachOptions)
|
|
196
|
+
console.log(created)
|
|
177
197
|
// check preventUpdate for an array (Line: 87)
|
|
178
198
|
if (options.preventUpdate !== true && element.on && isFunction(element.on.update)) {
|
|
179
199
|
applyEvent(element.on.update, created, created.state)
|
|
@@ -218,7 +238,7 @@ const inheritStateUpdates = (element, options) => {
|
|
|
218
238
|
const shouldForceFunctionState = isFunction(stateKey) && !isHoisted && execStateFunction
|
|
219
239
|
if (shouldForceFunctionState) {
|
|
220
240
|
const execState = exec(stateKey, element)
|
|
221
|
-
state.set(execState, { ...options, preventUpdate: true })
|
|
241
|
+
state.set(execState, { ...options, preventUpdate: true, updatedByStateFunction: true })
|
|
222
242
|
return
|
|
223
243
|
}
|
|
224
244
|
|