@mintjamsinc/ichigojs 0.1.79 → 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.
@@ -16,6 +16,35 @@ export declare class VNode {
16
16
  * @param args The initialization arguments for the virtual node.
17
17
  */
18
18
  constructor(args: VNodeInit);
19
+ /**
20
+ * Expands the component elements this application compiled in this subtree
21
+ * but has not expanded yet, parents before their children.
22
+ *
23
+ * This is the ONLY thing that expands a component. It is deliberately a
24
+ * separate step from compilation rather than a call at the end of the
25
+ * constructor: a v-if / v-for clone is compiled while it is still detached
26
+ * (so that its directives run before anything can observe a half-built
27
+ * subtree), and expanding a detached element would mount a component
28
+ * application outside the document. The callers therefore compile, insert,
29
+ * and then call this — see VApplication.mount, VConditionalDirective,
30
+ * VForDirective and VSlotOutletDirective.
31
+ *
32
+ * Walking only {@link childVNodes} keeps the traversal inside this
33
+ * application: the internals of an expanded component were never compiled
34
+ * here, so they are not reachable and are left to their own application.
35
+ * The one exception is content a directive rendered outside its own
36
+ * children — scoped slot content — reached through
37
+ * {@link VDirective.expandComponents}.
38
+ *
39
+ * Only connected elements are expanded. v-if / v-for call this right after
40
+ * inserting a clone, but when that clone sits inside another clone that is
41
+ * still detached (nested directives, or slot content rendered by an outlet
42
+ * inside a component's v-if), the insertion is not into the document yet;
43
+ * the outer inserter's walk reaches the same nodes once it is. A
44
+ * templatized node (a v-if / v-for source) is not expanded itself, but its
45
+ * rendered clones are its children and are walked.
46
+ */
47
+ expandComponents(): void;
19
48
  /**
20
49
  * The application instance associated with this virtual node.
21
50
  */
@@ -14,6 +14,19 @@ export interface ScopedSlotEntry {
14
14
  /**
15
15
  * Base class for ichigo.js-backed Web Components (Light DOM, no Shadow DOM).
16
16
  *
17
+ * Expansion — cloning the template into this element — is driven by the
18
+ * application that owns the element, not by connectedCallback: VNode compiles
19
+ * the element first (installing the host context, delivering the prop values
20
+ * and compiling the authored slot content in the owner's scope) and only then
21
+ * calls {@link _ichigoExpand}. That leaves connectedCallback a single job,
22
+ * re-attachment; see there.
23
+ *
24
+ * The component's <template> must be present in the document, and
25
+ * defineComponent() must have run, before the owning application is mounted.
26
+ * That is the application's responsibility. A missing template is reported as
27
+ * a warning and the element is left empty — it is never silently retried,
28
+ * because an app that renders anyway is an app whose bug cannot be found.
29
+ *
17
30
  * Mount timing:
18
31
  * - If the component declares no props, the VApplication is mounted synchronously
19
32
  * at the end of connectedCallback (the template is known, no props to wait for).
@@ -40,19 +53,6 @@ export declare class IchigoElement extends HTMLElement {
40
53
  * belong to this component's VApplication and scope).
41
54
  */
42
55
  _ichigoExpanded: boolean;
43
- /**
44
- * True when this element came from an enclosing component's template clone
45
- * (marked by that component while it expands). Such an element connects
46
- * while the enclosing component is attaching its template — before that
47
- * component's VApplication exists — so it must wait to be compiled by the
48
- * owning application before expanding itself (see connectedCallback guard
49
- * 0a2 and {@link _ichigoTryExpand}).
50
- *
51
- * Declared with `declare` for the same reason as {@link _ichigoHost}: the
52
- * mark is set before the element is upgraded, and a real class field would
53
- * be re-defined as undefined by the upgrade.
54
- */
55
- _ichigoTemplateOwned?: boolean;
56
56
  /**
57
57
  * Host context installed by the parent application's VNode when it
58
58
  * compiles this element. Gives component-boundary features (e.g. scoped
@@ -76,18 +76,39 @@ export declare class IchigoElement extends HTMLElement {
76
76
  * VSlotOutletDirective when the component template renders a `<slot>`.
77
77
  */
78
78
  get _ichigoScopedSlots(): Map<string, ScopedSlotEntry> | undefined;
79
+ /**
80
+ * Handles RE-attachment, and nothing else.
81
+ *
82
+ * A first connection is not what expands this element: the owning
83
+ * application does that from {@link _ichigoExpand} once it has compiled the
84
+ * element. So a connection event on a not-yet-expanded element means the
85
+ * owner has not reached it yet, and the right thing to do is nothing. That
86
+ * covers every case the old guards enumerated one by one — a v-if / v-for
87
+ * template source, an element inside an enclosing component's template
88
+ * clone, a clone inserted before its directive expands it.
89
+ *
90
+ * An expanded element whose mount root has been torn down, on the other
91
+ * hand, was disconnected and is now coming back: v-for reorders relocate
92
+ * the host element, which disconnects and reconnects it. Its children are
93
+ * the previous expansion, not authored slot content, so it re-expands from
94
+ * the cached slot nodes. Testing the mount root rather than the expansion
95
+ * flag alone keeps this from firing on an element that was expanded while
96
+ * detached and is being inserted for the first time.
97
+ */
79
98
  connectedCallback(): void;
80
- disconnectedCallback(): void;
81
99
  /**
82
- * Expands this element's template on behalf of the application that owns
83
- * it. Called by VNode right after it compiled this element — the host
84
- * context is installed and the prop bindings have delivered their values,
85
- * so a component that deferred its expansion (guard 0a2, or a template
86
- * that was not loaded when it connected) can now expand in the right
87
- * order. A no-op when the element is already expanded or not connected
88
- * (a template-source clone expands when it is inserted).
100
+ * Expands this element's template. Called by the application that owns the
101
+ * element, right after it compiled it (VNode.expandComponents): the host
102
+ * context is installed, the prop bindings have delivered their values and
103
+ * the authored slot content has been compiled in the owner's scope, so the
104
+ * capture below sees owner-compiled nodes and the component's own
105
+ * application starts with its props already in hand.
106
+ *
107
+ * Also called by {@link connectedCallback} to rebuild the expansion after a
108
+ * move.
89
109
  */
90
- _ichigoTryExpand(): void;
110
+ _ichigoExpand(): void;
111
+ disconnectedCallback(): void;
91
112
  /**
92
113
  * Called by the property setters generated by defineComponent().
93
114
  * Before mount: stores the value and schedules a mount microtask.
@@ -88,6 +88,14 @@ export interface VDirective {
88
88
  * The element reference is still available at this point.
89
89
  */
90
90
  get onUnmounted(): (() => void) | undefined;
91
+ /**
92
+ * Expands the components in a subtree this directive rendered but that is
93
+ * not reachable through the VNode's children — the scoped slot content of
94
+ * a `<slot>` outlet, whose VNodes belong to the parent application.
95
+ * Called by VNode.expandComponents() when it walks this directive's node.
96
+ * Optional; most directives render nothing outside their own VNode tree.
97
+ */
98
+ expandComponents?(): void;
91
99
  /**
92
100
  * Cleans up any resources used by the directive.
93
101
  * This method is called when the directive is no longer needed.
@@ -111,4 +111,8 @@ export declare class VSlotOutletDirective implements VDirective {
111
111
  * @inheritdoc
112
112
  */
113
113
  destroy(): void;
114
+ /**
115
+ * @inheritdoc
116
+ */
117
+ expandComponents(): void;
114
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintjamsinc/ichigojs",
3
- "version": "0.1.79",
3
+ "version": "0.1.81",
4
4
  "description": "ichigo.js - Simple and intuitive reactive framework. Lightweight, fast, and user-friendly virtual DOM library",
5
5
  "main": "./dist/ichigo.cjs",
6
6
  "module": "./dist/ichigo.esm.js",