@reckona/mreact-compat 0.0.144 → 0.0.146

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.
@@ -1,4 +1,4 @@
1
- import { Activity, ERROR_BOUNDARY_TYPE, FORWARD_REF_TYPE, Fragment, HOST_CHILDREN_ONLY_PROPS_META, HOST_OWN_PROPS_META, LAZY_TYPE, MEMO_TYPE, Profiler, STRICT_MODE_TYPE, Suspense, SuspenseList, isReactCompatElement, isReactCompatPortal, } from "./element.js";
1
+ import { Activity, ERROR_BOUNDARY_TYPE, FORWARD_REF_TYPE, Fragment, HOST_CHILDREN_ONLY_PROPS_META, HOST_OWN_PROPS_META, LAZY_TYPE, MEMO_TYPE, Profiler, REACTIVE_TEXT_BINDING_META, STRICT_MODE_TYPE, Suspense, SuspenseList, isReactCompatElement, isReactCompatPortal, } from "./element.js";
2
2
  import { consumerContext, isReactCompatConsumer, isReactCompatProvider, renderWithContextProvider, useContext, } from "./context.js";
3
3
  import { applyPostChildFormProps, applyProps } from "./dom-props.js";
4
4
  import { syncChildNodes, syncOwnedChildNodes, syncScopedChildNodes } from "./dom-children.js";
@@ -6,7 +6,7 @@ import { setLogicalEventParent } from "./host-event-binder.js";
6
6
  import { NoFlags, Placement, Update } from "./fiber-flags.js";
7
7
  import { createHostElement, hostElementMatches, isHostElement, namespaceForHostChildren, namespaceForHostElement, } from "./dom-host-rules.js";
8
8
  import { createFiber, createWorkInProgress } from "./fiber.js";
9
- import { renderWithRootRuntime, renderWithProfiler, renderWithStrictModeMemoCapture, renderStrictModeReplay, runWithHostCommit, restoreRuntimeSnapshot, takeRuntimeSnapshot, getDevToolsHookState, collectRuntimeInstanceKeys, hasContextDependency, hasChangedContextDependency, } from "./hooks.js";
9
+ import { renderWithRootRuntime, renderWithProfiler, renderWithStrictModeMemoCapture, renderStrictModeReplay, runWithHostCommit, restoreRuntimeSnapshot, takeRuntimeSnapshot, getDevToolsHookState, collectRuntimeInstanceKeys, hasContextDependency, hasChangedContextDependency, subscribeReactiveTextBinding, } from "./hooks.js";
10
10
  import { isThenable } from "./thenable.js";
11
11
  import { hasDirtyClassUpdate, isClassComponentType, recoverClassComponentError, renderClassComponentWithRuntime, } from "./class-component.js";
12
12
  import { areMemoPropsEqual, getPendingProps, shallowEqual } from "./prop-comparison.js";
@@ -1026,14 +1026,13 @@ function commitHostDirtyFiber(fiber, parent, eventRoot, path, options = {}) {
1026
1026
  applyChangedRef(previousProps?.ref, props.ref, element);
1027
1027
  }
1028
1028
  if (directTextChild !== undefined) {
1029
- syncDirectHostTextChild(element, directTextChild);
1029
+ const text = syncDirectHostTextChild(element, directTextChild);
1030
+ subscribeReactiveHostTextBinding(props, text);
1030
1031
  }
1031
1032
  else if (fiber.subtreeFlags !== NoFlags) {
1032
1033
  commitHostDirtyChildren(fiber.child, element, eventRoot, `${path}.c`, options);
1033
1034
  }
1034
- if (!propsAreUnchanged && !propsAreChildrenOnly && !textOnlyRowUpdate) {
1035
- applyPostChildFormProps(element, props);
1036
- }
1035
+ applyPostChildFormProps(element, props, previousProps);
1037
1036
  fiber.memoizedProps = props;
1038
1037
  finishCommittedFiber(fiber);
1039
1038
  return;
@@ -1299,7 +1298,8 @@ function commitHostFiber(fiber, parent, eventRoot, path, options = {}) {
1299
1298
  applyChangedRef(previousProps?.ref, props.ref, element);
1300
1299
  }
1301
1300
  if (directTextChild !== undefined) {
1302
- syncDirectHostTextChild(element, directTextChild);
1301
+ const text = syncDirectHostTextChild(element, directTextChild);
1302
+ subscribeReactiveHostTextBinding(props, text);
1303
1303
  }
1304
1304
  else if (fiber.hostChildListChanged ||
1305
1305
  fiber.childListChanged ||
@@ -1314,9 +1314,7 @@ function commitHostFiber(fiber, parent, eventRoot, path, options = {}) {
1314
1314
  else if (fiber.subtreeFlags !== NoFlags) {
1315
1315
  commitHostChildren(fiber.child, element, eventRoot, `${path}.c`, options);
1316
1316
  }
1317
- if (!propsAreUnchanged && !propsAreChildrenOnly && !textOnlyRowUpdate) {
1318
- applyPostChildFormProps(element, props);
1319
- }
1317
+ applyPostChildFormProps(element, props, previousProps);
1320
1318
  fiber.memoizedProps = props;
1321
1319
  finishCommittedFiber(fiber);
1322
1320
  return [element];
@@ -1588,9 +1586,19 @@ function syncDirectHostTextChild(element, text) {
1588
1586
  if (firstChild.data !== text) {
1589
1587
  firstChild.data = text;
1590
1588
  }
1591
- return;
1589
+ return firstChild;
1592
1590
  }
1593
1591
  element.textContent = text;
1592
+ const nextFirstChild = element.firstChild;
1593
+ if (!(nextFirstChild instanceof Text)) {
1594
+ const textNode = document.createTextNode(text);
1595
+ element.replaceChildren(textNode);
1596
+ return textNode;
1597
+ }
1598
+ return nextFirstChild;
1599
+ }
1600
+ function subscribeReactiveHostTextBinding(props, text) {
1601
+ subscribeReactiveTextBinding(props[REACTIVE_TEXT_BINDING_META], text);
1594
1602
  }
1595
1603
  function shouldPreserveContentEditableChildren(element, props, childNodes) {
1596
1604
  void childNodes;