@mintjamsinc/ichigojs 0.1.80 → 0.1.81

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.
@@ -9239,9 +9239,18 @@ class VSlotOutletDirective {
9239
9239
  slot.replaceWith(fragment);
9240
9240
  // Initial rendering
9241
9241
  this.#contentVNode.forceUpdate();
9242
- // Components in the slot content expand once it is in the document.
9242
+ // Components in the slot content expand once it is in the document:
9243
+ // now, if the outlet is connected, or — when it renders inside a
9244
+ // detached v-if / v-for clone — through expandComponents() below, when
9245
+ // the directive that inserts the clone walks it.
9243
9246
  this.#contentVNode.expandComponents();
9244
9247
  }
9248
+ /**
9249
+ * @inheritdoc
9250
+ */
9251
+ expandComponents() {
9252
+ this.#contentVNode?.expandComponents();
9253
+ }
9245
9254
  /**
9246
9255
  * Re-evaluates the slot props (component-side change) and pushes them into
9247
9256
  * the content scope.
@@ -9857,6 +9866,12 @@ class VNode {
9857
9866
  * remove the entire fragment atomically.
9858
9867
  */
9859
9868
  #fragmentRange;
9869
+ /**
9870
+ * Set by {@link destroy}. A destroyed clone stays in its parent's child
9871
+ * list (v-if / v-for render new clones under the same parent), so walks
9872
+ * over the children must skip it.
9873
+ */
9874
+ #destroyed = false;
9860
9875
  /**
9861
9876
  * Custom element tags already reported by
9862
9877
  * {@link VNode.#warnIfUnknownCustomElement}.
@@ -9990,19 +10005,40 @@ class VNode {
9990
10005
  * Walking only {@link childVNodes} keeps the traversal inside this
9991
10006
  * application: the internals of an expanded component were never compiled
9992
10007
  * here, so they are not reachable and are left to their own application.
9993
- * A templatized node is skipped whole — it is a template source, and its
9994
- * clones expand when they are inserted.
10008
+ * The one exception is content a directive rendered outside its own
10009
+ * children — scoped slot content — reached through
10010
+ * {@link VDirective.expandComponents}.
10011
+ *
10012
+ * Only connected elements are expanded. v-if / v-for call this right after
10013
+ * inserting a clone, but when that clone sits inside another clone that is
10014
+ * still detached (nested directives, or slot content rendered by an outlet
10015
+ * inside a component's v-if), the insertion is not into the document yet;
10016
+ * the outer inserter's walk reaches the same nodes once it is. A
10017
+ * templatized node (a v-if / v-for source) is not expanded itself, but its
10018
+ * rendered clones are its children and are walked.
9995
10019
  */
9996
10020
  expandComponents() {
9997
- if (this.#templatized) {
10021
+ if (this.#destroyed) {
9998
10022
  return;
9999
10023
  }
10000
- if (this.#nodeType === Node.ELEMENT_NODE && IchigoElementRegistry.has(this.#nodeName)) {
10024
+ // Expand only a connected element. A subtree compiled and inserted
10025
+ // into a still-detached clone (a v-if / v-for nested in another
10026
+ // clone, or in scoped slot content rendered inside one) is reached
10027
+ // again by the walk of whoever inserts that clone into the document —
10028
+ // and by then its elements are upgraded and ready to expand.
10029
+ // A templatized node is a template source: never expanded itself,
10030
+ // but its rendered clones are its child VNodes and are walked below.
10031
+ if (!this.#templatized && this.#nodeType === Node.ELEMENT_NODE && IchigoElementRegistry.has(this.#nodeName)) {
10001
10032
  const element = this.#node;
10002
- if (element._ichigoExpanded !== true) {
10033
+ if (element._ichigoExpanded !== true && element.isConnected) {
10003
10034
  element._ichigoExpand?.();
10004
10035
  }
10005
10036
  }
10037
+ // Subtrees a directive rendered outside this VNode's children (the
10038
+ // scoped slot content of a <slot> outlet) are expanded here too: this
10039
+ // walk runs once the subtree is in the document, which the outlet
10040
+ // cannot know when it renders inside a detached v-if / v-for clone.
10041
+ this.#directiveManager?.directives?.forEach(d => d.expandComponents?.());
10006
10042
  this.#childVNodes?.forEach(child => child.expandComponents());
10007
10043
  }
10008
10044
  /**
@@ -10412,6 +10448,7 @@ class VNode {
10412
10448
  * 6. Call onUnmounted lifecycle hooks
10413
10449
  */
10414
10450
  destroy() {
10451
+ this.#destroyed = true;
10415
10452
  // If no directive requires template preservation, call onUnmount for directives that do not templatize
10416
10453
  if (!this.#templatized) {
10417
10454
  this.#directiveManager?.directives?.forEach(d => {