@reckona/mreact-compat 0.0.163 → 0.0.164
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/dom-props.d.ts.map +1 -1
- package/dist/dom-props.js +8 -0
- package/dist/dom-props.js.map +1 -1
- package/dist/fiber-child.js +11 -5
- package/dist/fiber-child.js.map +1 -1
- package/dist/host-reconciler.js +7 -18
- package/dist/host-reconciler.js.map +1 -1
- package/package.json +3 -3
- package/src/dom-props.ts +14 -0
- package/src/fiber-child.ts +12 -5
- package/src/host-reconciler.ts +9 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reckona/mreact-compat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.164",
|
|
4
4
|
"description": "React-compatible runtime implementation for mreact.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compatibility",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@reckona/mreact-
|
|
73
|
-
"@reckona/mreact-
|
|
72
|
+
"@reckona/mreact-reactive-core": "0.0.164",
|
|
73
|
+
"@reckona/mreact-shared": "0.0.164"
|
|
74
74
|
}
|
|
75
75
|
}
|
package/src/dom-props.ts
CHANGED
|
@@ -283,6 +283,10 @@ export function applyPostChildFormProps(
|
|
|
283
283
|
props: Record<string, unknown>,
|
|
284
284
|
previousProps?: Record<string, unknown>,
|
|
285
285
|
): void {
|
|
286
|
+
if (!isPostChildFormElement(element)) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
286
290
|
if (element instanceof HTMLInputElement) {
|
|
287
291
|
if (hasOwnProp(props, "checked")) {
|
|
288
292
|
const checked = props.checked !== null && props.checked !== undefined && props.checked !== false;
|
|
@@ -322,6 +326,16 @@ export function applyPostChildFormProps(
|
|
|
322
326
|
}
|
|
323
327
|
}
|
|
324
328
|
|
|
329
|
+
function isPostChildFormElement(
|
|
330
|
+
element: Element,
|
|
331
|
+
): element is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement {
|
|
332
|
+
return (
|
|
333
|
+
element instanceof HTMLInputElement ||
|
|
334
|
+
element instanceof HTMLTextAreaElement ||
|
|
335
|
+
element instanceof HTMLSelectElement
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
325
339
|
function postChildFormValue(
|
|
326
340
|
props: Record<string, unknown>,
|
|
327
341
|
previousProps: Record<string, unknown> | undefined,
|
package/src/fiber-child.ts
CHANGED
|
@@ -106,13 +106,17 @@ function reconcileSameKeyOrderChildren(
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
let cursor: Fiber | undefined = currentFirstChild;
|
|
109
|
+
let matchedCount = 0;
|
|
109
110
|
|
|
110
111
|
for (const child of children) {
|
|
112
|
+
if (cursor === undefined) {
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
|
|
111
116
|
const key = getNodeKey(child);
|
|
112
117
|
|
|
113
118
|
if (
|
|
114
119
|
key === undefined ||
|
|
115
|
-
cursor === undefined ||
|
|
116
120
|
cursor.key !== key ||
|
|
117
121
|
!isReactCompatElement(child) ||
|
|
118
122
|
!canReuseElementFiber(cursor, child)
|
|
@@ -121,9 +125,10 @@ function reconcileSameKeyOrderChildren(
|
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
cursor = cursor.sibling;
|
|
128
|
+
matchedCount += 1;
|
|
124
129
|
}
|
|
125
130
|
|
|
126
|
-
if (cursor !== undefined) {
|
|
131
|
+
if (matchedCount === 0 || cursor !== undefined) {
|
|
127
132
|
return undefined;
|
|
128
133
|
}
|
|
129
134
|
|
|
@@ -131,9 +136,11 @@ function reconcileSameKeyOrderChildren(
|
|
|
131
136
|
let first: Fiber | undefined;
|
|
132
137
|
let previous: Fiber | undefined;
|
|
133
138
|
|
|
134
|
-
for (
|
|
139
|
+
for (let index = 0; index < children.length; index += 1) {
|
|
140
|
+
const child = children[index] as ReactCompatNode;
|
|
135
141
|
const key = getNodeKey(child) as string;
|
|
136
|
-
const
|
|
142
|
+
const matchedCurrent: Fiber | undefined = index < matchedCount ? cursor : undefined;
|
|
143
|
+
const fiber = reconcileSingleChild(parent, matchedCurrent, child, key) as Fiber;
|
|
137
144
|
|
|
138
145
|
fiber.lanes |= parent.lanes;
|
|
139
146
|
fiber.return = parent;
|
|
@@ -146,7 +153,7 @@ function reconcileSameKeyOrderChildren(
|
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
previous = fiber;
|
|
149
|
-
cursor =
|
|
156
|
+
cursor = matchedCurrent?.sibling;
|
|
150
157
|
}
|
|
151
158
|
|
|
152
159
|
parent.child = first;
|
package/src/host-reconciler.ts
CHANGED
|
@@ -435,10 +435,7 @@ function reconcileKeyedRowHostChildren(
|
|
|
435
435
|
let subtreeFlags = NoFlags;
|
|
436
436
|
let subtreeChildListChanged = false;
|
|
437
437
|
let hasRefSubtree = false;
|
|
438
|
-
const
|
|
439
|
-
const canReuseUnchangedRows =
|
|
440
|
-
currentSiblingCount === children.length ||
|
|
441
|
-
isKeyedAppendOnly(currentFirstChild, children, currentSiblingCount);
|
|
438
|
+
const canReuseUnchangedRows = hasSameKeyOrderPrefix(currentFirstChild, children);
|
|
442
439
|
const row = createKeyedRowHostElementScratch();
|
|
443
440
|
|
|
444
441
|
for (let index = 0; index < children.length; index += 1) {
|
|
@@ -514,33 +511,21 @@ function reconcileKeyedRowHostChildren(
|
|
|
514
511
|
return { fiber: first, consumed: 0 };
|
|
515
512
|
}
|
|
516
513
|
|
|
517
|
-
function
|
|
518
|
-
let count = 0;
|
|
519
|
-
let cursor: Fiber | undefined = first;
|
|
520
|
-
|
|
521
|
-
while (cursor !== undefined) {
|
|
522
|
-
count += 1;
|
|
523
|
-
cursor = cursor.sibling;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
return count;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
function isKeyedAppendOnly(
|
|
514
|
+
function hasSameKeyOrderPrefix(
|
|
530
515
|
currentFirstChild: Fiber,
|
|
531
516
|
children: readonly ReactCompatNode[],
|
|
532
|
-
currentSiblingCount: number,
|
|
533
517
|
): boolean {
|
|
534
|
-
if (children.length <= currentSiblingCount) {
|
|
535
|
-
return false;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
518
|
let current: Fiber | undefined = currentFirstChild;
|
|
539
519
|
|
|
540
|
-
for (let index = 0; index <
|
|
541
|
-
if (current === undefined
|
|
520
|
+
for (let index = 0; index < children.length; index += 1) {
|
|
521
|
+
if (current === undefined) {
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (current.key !== getNodeKey(children[index])) {
|
|
542
526
|
return false;
|
|
543
527
|
}
|
|
528
|
+
|
|
544
529
|
current = current.sibling;
|
|
545
530
|
}
|
|
546
531
|
|