@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.
package/dist/ichigo.cjs CHANGED
@@ -9245,9 +9245,18 @@
9245
9245
  slot.replaceWith(fragment);
9246
9246
  // Initial rendering
9247
9247
  this.#contentVNode.forceUpdate();
9248
- // Components in the slot content expand once it is in the document.
9248
+ // Components in the slot content expand once it is in the document:
9249
+ // now, if the outlet is connected, or — when it renders inside a
9250
+ // detached v-if / v-for clone — through expandComponents() below, when
9251
+ // the directive that inserts the clone walks it.
9249
9252
  this.#contentVNode.expandComponents();
9250
9253
  }
9254
+ /**
9255
+ * @inheritdoc
9256
+ */
9257
+ expandComponents() {
9258
+ this.#contentVNode?.expandComponents();
9259
+ }
9251
9260
  /**
9252
9261
  * Re-evaluates the slot props (component-side change) and pushes them into
9253
9262
  * the content scope.
@@ -9863,6 +9872,12 @@
9863
9872
  * remove the entire fragment atomically.
9864
9873
  */
9865
9874
  #fragmentRange;
9875
+ /**
9876
+ * Set by {@link destroy}. A destroyed clone stays in its parent's child
9877
+ * list (v-if / v-for render new clones under the same parent), so walks
9878
+ * over the children must skip it.
9879
+ */
9880
+ #destroyed = false;
9866
9881
  /**
9867
9882
  * Custom element tags already reported by
9868
9883
  * {@link VNode.#warnIfUnknownCustomElement}.
@@ -9996,19 +10011,40 @@
9996
10011
  * Walking only {@link childVNodes} keeps the traversal inside this
9997
10012
  * application: the internals of an expanded component were never compiled
9998
10013
  * here, so they are not reachable and are left to their own application.
9999
- * A templatized node is skipped whole — it is a template source, and its
10000
- * clones expand when they are inserted.
10014
+ * The one exception is content a directive rendered outside its own
10015
+ * children — scoped slot content — reached through
10016
+ * {@link VDirective.expandComponents}.
10017
+ *
10018
+ * Only connected elements are expanded. v-if / v-for call this right after
10019
+ * inserting a clone, but when that clone sits inside another clone that is
10020
+ * still detached (nested directives, or slot content rendered by an outlet
10021
+ * inside a component's v-if), the insertion is not into the document yet;
10022
+ * the outer inserter's walk reaches the same nodes once it is. A
10023
+ * templatized node (a v-if / v-for source) is not expanded itself, but its
10024
+ * rendered clones are its children and are walked.
10001
10025
  */
10002
10026
  expandComponents() {
10003
- if (this.#templatized) {
10027
+ if (this.#destroyed) {
10004
10028
  return;
10005
10029
  }
10006
- if (this.#nodeType === Node.ELEMENT_NODE && IchigoElementRegistry.has(this.#nodeName)) {
10030
+ // Expand only a connected element. A subtree compiled and inserted
10031
+ // into a still-detached clone (a v-if / v-for nested in another
10032
+ // clone, or in scoped slot content rendered inside one) is reached
10033
+ // again by the walk of whoever inserts that clone into the document —
10034
+ // and by then its elements are upgraded and ready to expand.
10035
+ // A templatized node is a template source: never expanded itself,
10036
+ // but its rendered clones are its child VNodes and are walked below.
10037
+ if (!this.#templatized && this.#nodeType === Node.ELEMENT_NODE && IchigoElementRegistry.has(this.#nodeName)) {
10007
10038
  const element = this.#node;
10008
- if (element._ichigoExpanded !== true) {
10039
+ if (element._ichigoExpanded !== true && element.isConnected) {
10009
10040
  element._ichigoExpand?.();
10010
10041
  }
10011
10042
  }
10043
+ // Subtrees a directive rendered outside this VNode's children (the
10044
+ // scoped slot content of a <slot> outlet) are expanded here too: this
10045
+ // walk runs once the subtree is in the document, which the outlet
10046
+ // cannot know when it renders inside a detached v-if / v-for clone.
10047
+ this.#directiveManager?.directives?.forEach(d => d.expandComponents?.());
10012
10048
  this.#childVNodes?.forEach(child => child.expandComponents());
10013
10049
  }
10014
10050
  /**
@@ -10418,6 +10454,7 @@
10418
10454
  * 6. Call onUnmounted lifecycle hooks
10419
10455
  */
10420
10456
  destroy() {
10457
+ this.#destroyed = true;
10421
10458
  // If no directive requires template preservation, call onUnmount for directives that do not templatize
10422
10459
  if (!this.#templatized) {
10423
10460
  this.#directiveManager?.directives?.forEach(d => {