@estjs/template 0.0.17-beta.6 → 0.0.17-beta.7

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.
@@ -822,17 +822,18 @@ function triggerUpdateHooks(scope) {
822
822
 
823
823
  // src/component.ts
824
824
  function syncDescriptors(target, source, pruneMissing = false) {
825
- for (const key of Object.getOwnPropertyNames(source)) {
825
+ const sourceKeys = Reflect.ownKeys(source);
826
+ for (const key of sourceKeys) {
826
827
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
827
828
  }
828
829
  if (pruneMissing) {
829
- const sourceKeySet = new Set(Object.getOwnPropertyNames(source));
830
- for (const key of Object.getOwnPropertyNames(target)) {
830
+ const sourceKeySet = new Set(sourceKeys);
831
+ for (const key of Reflect.ownKeys(target)) {
831
832
  if (!sourceKeySet.has(key)) delete target[key];
832
833
  }
833
834
  }
834
835
  }
835
- function readProp(source, key) {
836
+ function readDescriptorValue(source, key) {
836
837
  const descriptor = Object.getOwnPropertyDescriptor(source, key);
837
838
  return descriptor.get ? descriptor.get.call(source) : descriptor.value;
838
839
  }
@@ -851,9 +852,9 @@ var Component = class {
851
852
  this.parentNode = void 0;
852
853
  this.rootEventCleanups = [];
853
854
  this.parentScope = getActiveScope();
854
- const container = {};
855
- syncDescriptors(container, props);
856
- this.reactiveProps = shallowReactive(container);
855
+ const reactiveProps = /* @__PURE__ */ Object.create(null);
856
+ syncDescriptors(reactiveProps, props);
857
+ this.reactiveProps = shallowReactive(reactiveProps);
857
858
  }
858
859
  /**
859
860
  * Mount the component into `parentNode` (optionally before `beforeNode`).
@@ -901,14 +902,14 @@ var Component = class {
901
902
  */
902
903
  update(props) {
903
904
  this.props = props;
904
- const scope = this.scope;
905
- if (!scope || scope.isDestroyed) return;
906
905
  syncDescriptors(
907
906
  this.reactiveProps,
908
907
  props != null ? props : {},
909
908
  /* pruneMissing */
910
909
  true
911
910
  );
911
+ const scope = this.scope;
912
+ if (!scope || scope.isDestroyed) return;
912
913
  this.syncSpecialProps(props);
913
914
  triggerUpdateHooks(scope);
914
915
  }
@@ -920,7 +921,10 @@ var Component = class {
920
921
  if (!this.parentNode) return;
921
922
  const parent = this.parentNode;
922
923
  const before = this.beforeNode;
924
+ const savedProps = /* @__PURE__ */ Object.create(null);
925
+ syncDescriptors(savedProps, this.reactiveProps);
923
926
  this.destroy();
927
+ syncDescriptors(this.reactiveProps, savedProps);
924
928
  this.mount(parent, before);
925
929
  }
926
930
  /**
@@ -937,7 +941,7 @@ var Component = class {
937
941
  this.renderedNodes = [];
938
942
  this.firstChild = void 0;
939
943
  this.parentNode = void 0;
940
- for (const key of Object.getOwnPropertyNames(this.reactiveProps)) {
944
+ for (const key of Reflect.ownKeys(this.reactiveProps)) {
941
945
  delete this.reactiveProps[key];
942
946
  }
943
947
  this.state = 0 /* INITIAL */;
@@ -953,35 +957,42 @@ var Component = class {
953
957
  const root = this.firstChild;
954
958
  if (!root || !(root instanceof Element)) return;
955
959
  this.releaseSpecialProps();
956
- for (const key of Object.getOwnPropertyNames(props)) {
960
+ for (const key of Reflect.ownKeys(props)) {
961
+ if (!isString(key)) continue;
957
962
  if (key === REF_KEY) {
958
- const value = readProp(props, key);
963
+ const value = readDescriptorValue(props, key);
959
964
  this.rootRefCleanup = this.bindRootRef(value, root);
960
965
  continue;
961
966
  }
962
967
  if (isOn(key)) {
963
- const value = readProp(props, key);
968
+ const value = readDescriptorValue(props, key);
964
969
  if (!isFunction(value)) continue;
965
970
  const eventName = key.slice(2).toLowerCase();
966
- const target = root;
967
- const slot = `_$${eventName}`;
968
- const prev = target[slot];
969
- if (isFunction(prev)) {
970
- target[slot] = value;
971
- this.rootEventCleanups.push(() => {
972
- if (target[slot] === value) target[slot] = prev;
973
- });
974
- continue;
975
- }
976
- const fn = value;
977
- const handler = (event) => {
978
- if (target.disabled) return;
979
- fn.call(target, event);
980
- };
981
- this.rootEventCleanups.push(addEvent(target, eventName, handler));
971
+ this.bindRootEvent(
972
+ root,
973
+ eventName,
974
+ value
975
+ );
982
976
  }
983
977
  }
984
978
  }
979
+ bindRootEvent(target, eventName, handler) {
980
+ const slot = `_$${eventName}`;
981
+ const prev = target[slot];
982
+ if (isFunction(prev)) {
983
+ target[slot] = handler;
984
+ this.rootEventCleanups.push(() => {
985
+ if (target[slot] === handler) target[slot] = prev;
986
+ });
987
+ return;
988
+ }
989
+ this.rootEventCleanups.push(
990
+ addEvent(target, eventName, (event) => {
991
+ if (target.disabled) return;
992
+ handler.call(target, event);
993
+ })
994
+ );
995
+ }
985
996
  /**
986
997
  * Remove all listeners/ref bindings currently attached to the root element.
987
998
  */
@@ -1203,6 +1214,7 @@ function eventHandler(e) {
1203
1214
  }
1204
1215
  var $EVENTS = /* @__PURE__ */ Symbol("_$EVENTS");
1205
1216
  function delegateEvents(eventNames, document2 = globalThis.document) {
1217
+ if (!document2) return;
1206
1218
  const docWithEvents = document2;
1207
1219
  const eventSet = docWithEvents[$EVENTS] || (docWithEvents[$EVENTS] = /* @__PURE__ */ new Set());
1208
1220
  for (const name of eventNames) {
@@ -1213,6 +1225,7 @@ function delegateEvents(eventNames, document2 = globalThis.document) {
1213
1225
  }
1214
1226
  }
1215
1227
  function clearDelegatedEvents(document2 = globalThis.document) {
1228
+ if (!document2) return;
1216
1229
  const docWithEvents = document2;
1217
1230
  const eventSet = docWithEvents[$EVENTS];
1218
1231
  if (eventSet) {