@stencil/core 5.0.0-beta.0 → 5.0.0-beta.10

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,2 +1,2 @@
1
- import { n as Env, r as NAMESPACE, t as BUILD } from "../index-DnISpqrd.js";
1
+ import { n as Env, r as NAMESPACE, t as BUILD } from "../index-BXAcVN2j.js";
2
2
  export { BUILD, Env, NAMESPACE };
@@ -996,16 +996,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
996
996
  const disposeSignalVNode = (vnode) => {
997
997
  const elm = vnode.$elm$;
998
998
  if (elm) {
999
- const dispose = signalNodeDisposers.get(elm);
1000
- if (dispose) {
1001
- dispose();
1002
- signalNodeDisposers.delete(elm);
1003
- }
999
+ disposeTextSignal(elm);
1004
1000
  disposeAllSignalAttrs(elm);
1005
1001
  }
1006
1002
  vnode.$children$?.forEach(disposeSignalVNode);
1007
1003
  };
1008
1004
  /**
1005
+ * Tear down a text node's signal subscription, if it has one.
1006
+ * @param textNode the text node to unsubscribe
1007
+ */
1008
+ const disposeTextSignal = (textNode) => {
1009
+ const dispose = signalNodeDisposers.get(textNode);
1010
+ if (dispose) {
1011
+ dispose();
1012
+ signalNodeDisposers.delete(textNode);
1013
+ }
1014
+ };
1015
+ /**
1016
+ * Subscribe a text node to a signal, keeping its `data` in sync on every change.
1017
+ * @param textNode the text node to keep in sync
1018
+ * @param textSig the signal to subscribe to
1019
+ */
1020
+ const wireTextSignal = (textNode, textSig) => {
1021
+ signalNodeDisposers.set(textNode, effect(() => {
1022
+ textNode.data = String(textSig.value);
1023
+ }));
1024
+ };
1025
+ /**
1009
1026
  * Create a DOM Node corresponding to one of the children of a given VNode.
1010
1027
  *
1011
1028
  * @param oldParentVNode the parent VNode from the previous render
@@ -1027,13 +1044,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
1027
1044
  if (BUILD.isDev && newVNode.$elm$) consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${String(newVNode.$tag$)}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
1028
1045
  if (BUILD.vdomText && newVNode.$text$ != null) {
1029
1046
  elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
1030
- if (BUILD.vdomSignals && newVNode.$signal$) {
1031
- const textSig = newVNode.$signal$;
1032
- const textNode = elm;
1033
- signalNodeDisposers.set(textNode, effect(() => {
1034
- textNode.data = String(textSig.value);
1035
- }));
1036
- }
1047
+ if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
1037
1048
  } else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
1038
1049
  elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
1039
1050
  if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
@@ -1394,7 +1405,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
1394
1405
  else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
1395
1406
  if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
1396
1407
  } else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
1397
- else if (BUILD.vdomText && oldVNode.$text$ !== text) elm.data = text;
1408
+ else if (BUILD.vdomText) {
1409
+ if (BUILD.vdomSignals && newVNode.$signal$) {
1410
+ if (newVNode.$signal$ !== oldVNode.$signal$) {
1411
+ disposeTextSignal(elm);
1412
+ wireTextSignal(elm, newVNode.$signal$);
1413
+ }
1414
+ } else {
1415
+ if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
1416
+ if (oldVNode.$text$ !== text) elm.data = text;
1417
+ }
1418
+ }
1398
1419
  };
1399
1420
  /**
1400
1421
  * Component-global information about nodes which are either currently being