what-core 0.7.0 → 0.8.1

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/render.js CHANGED
@@ -988,6 +988,10 @@ function setProp(el, key, value, isSvg) {
988
988
  }
989
989
 
990
990
  // packages/core/src/render.js
991
+ var _onTextInsert = null;
992
+ function _setTextInsertHook(fn) {
993
+ _onTextInsert = typeof fn === "function" ? fn : null;
994
+ }
991
995
  function _$createComponent(Component, props, children) {
992
996
  if (children && children.length > 0) {
993
997
  const mergedChildren = children.length === 1 ? children[0] : children;
@@ -1122,6 +1126,7 @@ function insert(parent, child, marker) {
1122
1126
  const m = marker || null;
1123
1127
  if (m) parent.insertBefore(textNode, m);
1124
1128
  else parent.appendChild(textNode);
1129
+ if (_onTextInsert) _onTextInsert(parent, String(first));
1125
1130
  let current2 = textNode;
1126
1131
  let isTextFastPath = true;
1127
1132
  effect(() => {
@@ -1130,6 +1135,7 @@ function insert(parent, child, marker) {
1130
1135
  if (isTextFastPath && (vt === "string" || vt === "number")) {
1131
1136
  const str = String(val);
1132
1137
  if (textNode.data !== str) textNode.data = str;
1138
+ if (_onTextInsert) _onTextInsert(parent, str);
1133
1139
  } else {
1134
1140
  isTextFastPath = false;
1135
1141
  current2 = reconcileInsert(parent, val, current2, m);
@@ -2038,6 +2044,7 @@ function hydrateElementProps(el, props) {
2038
2044
  export {
2039
2045
  _$createComponent,
2040
2046
  _$templateImpl as _$template,
2047
+ _setTextInsertHook,
2041
2048
  template as _template,
2042
2049
  classList,
2043
2050
  delegateEvents,