@mintjamsinc/ichigojs 0.1.14 → 0.1.15

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.
@@ -6962,14 +6962,13 @@
6962
6962
  */
6963
6963
  get domUpdater() {
6964
6964
  const identifiers = this.#dependentIdentifiers ?? [];
6965
- const render = () => this.#render();
6966
6965
  // Create an updater that handles the attribute binding
6967
6966
  const updater = {
6968
6967
  get dependentIdentifiers() {
6969
6968
  return identifiers;
6970
6969
  },
6971
- applyToDOM() {
6972
- render();
6970
+ applyToDOM: () => {
6971
+ this.#render();
6973
6972
  }
6974
6973
  };
6975
6974
  return updater;
@@ -7233,13 +7232,9 @@
7233
7232
  */
7234
7233
  #componentId;
7235
7234
  /**
7236
- * The child application instance for the component.
7237
- */
7238
- #childApp;
7239
- /**
7240
- * Whether the component has been activated.
7235
+ * The application instance for the component.
7241
7236
  */
7242
- #isActivated = false;
7237
+ #componentApp;
7243
7238
  constructor(context) {
7244
7239
  this.#vNode = context.vNode;
7245
7240
  this.#componentId = context.attribute.value.trim();
@@ -7262,7 +7257,7 @@
7262
7257
  * @inheritdoc
7263
7258
  */
7264
7259
  get needsAnchor() {
7265
- return false;
7260
+ return true;
7266
7261
  }
7267
7262
  /**
7268
7263
  * @inheritdoc
@@ -7280,9 +7275,7 @@
7280
7275
  return [];
7281
7276
  },
7282
7277
  applyToDOM: () => {
7283
- if (!this.#isActivated) {
7284
- this.#renderComponent();
7285
- }
7278
+ this.#render();
7286
7279
  }
7287
7280
  };
7288
7281
  return updater;
@@ -7291,7 +7284,7 @@
7291
7284
  * @inheritdoc
7292
7285
  */
7293
7286
  get templatize() {
7294
- return false;
7287
+ return true;
7295
7288
  }
7296
7289
  /**
7297
7290
  * @inheritdoc
@@ -7327,7 +7320,7 @@
7327
7320
  * @inheritdoc
7328
7321
  */
7329
7322
  get onUnmount() {
7330
- return () => this.#cleanupComponent();
7323
+ return undefined;
7331
7324
  }
7332
7325
  /**
7333
7326
  * @inheritdoc
@@ -7335,7 +7328,7 @@
7335
7328
  get onUnmounted() {
7336
7329
  return undefined;
7337
7330
  }
7338
- cloneNode() {
7331
+ #cloneNode() {
7339
7332
  // Get component definition from the application's component registry
7340
7333
  const component = this.#vNode.vApplication.componentRegistry.get(this.#componentId);
7341
7334
  if (!component) {
@@ -7362,12 +7355,29 @@
7362
7355
  * @inheritdoc
7363
7356
  */
7364
7357
  destroy() {
7365
- this.#cleanupComponent();
7358
+ if (!this.#componentApp) {
7359
+ // Not rendered, no action needed
7360
+ return;
7361
+ }
7362
+ // Destroy component application first (calls @unmount hooks while DOM is still accessible)
7363
+ this.#componentApp.unmount();
7364
+ // Then remove from DOM
7365
+ const componentVNode = this.#componentApp.rootVNode;
7366
+ if (componentVNode?.node.parentNode) {
7367
+ componentVNode.node.parentNode.removeChild(componentVNode.node);
7368
+ }
7369
+ this.#componentApp = undefined;
7366
7370
  }
7367
7371
  /**
7368
7372
  * Renders the component.
7369
7373
  */
7370
- #renderComponent() {
7374
+ #render() {
7375
+ if (this.#componentApp) {
7376
+ // Already rendered, no action needed
7377
+ return;
7378
+ }
7379
+ const clone = this.#cloneNode();
7380
+ this.#vNode.anchorNode?.parentNode?.insertBefore(clone, this.#vNode.anchorNode.nextSibling);
7371
7381
  // Get properties from :options or :options.component directive
7372
7382
  let properties = {};
7373
7383
  const optionsDirective = this.#vNode.directiveManager?.optionsDirective('component');
@@ -7391,19 +7401,8 @@
7391
7401
  // Create component instance
7392
7402
  const instance = component.createInstance(properties);
7393
7403
  // Create and mount child application using the parent application's registries
7394
- this.#childApp = this.#vNode.vApplication.createChildApp(instance);
7395
- this.#childApp.mount(this.#vNode.node);
7396
- this.#isActivated = true;
7397
- }
7398
- /**
7399
- * Cleans up the component.
7400
- */
7401
- #cleanupComponent() {
7402
- if (this.#childApp) {
7403
- this.#childApp.unmount();
7404
- this.#childApp = undefined;
7405
- }
7406
- this.#isActivated = false;
7404
+ this.#componentApp = this.#vNode.vApplication.createChildApp(instance);
7405
+ this.#componentApp.mount(clone);
7407
7406
  }
7408
7407
  }
7409
7408
 
@@ -7738,11 +7737,6 @@
7738
7737
  * The keys are directive names (e.g., 'options', 'options.intersection').
7739
7738
  */
7740
7739
  #optionsDirectives = {};
7741
- /**
7742
- * The v-component directive associated with this node, if any.
7743
- * This may be undefined if there is no v-component directive.
7744
- */
7745
- #componentDirective;
7746
7740
  constructor(vNode) {
7747
7741
  // Directives can only be associated with element nodes
7748
7742
  if (vNode.nodeType !== Node.ELEMENT_NODE) {
@@ -7800,13 +7794,6 @@
7800
7794
  get keyDirective() {
7801
7795
  return this.#keyDirective;
7802
7796
  }
7803
- /**
7804
- * Gets the v-component directive associated with this node, if any.
7805
- * This may be undefined if there is no v-component directive.
7806
- */
7807
- get componentDirective() {
7808
- return this.#componentDirective;
7809
- }
7810
7797
  /**
7811
7798
  * Gets the VBindDirective for options specific to the given directive name.
7812
7799
  * Searches in order: `:options.{directive}` -> `:options`
@@ -7896,10 +7883,6 @@
7896
7883
  this.#optionsDirectives[attrName] = bindDirective;
7897
7884
  }
7898
7885
  }
7899
- // If this is a v-component directive, store it separately
7900
- if (directive.name === StandardDirectiveName.V_COMPONENT) {
7901
- this.#componentDirective = directive;
7902
- }
7903
7886
  }
7904
7887
  }
7905
7888
  // Sort directives by priority: v-for > v-if > v-else-if > v-else > v-show > others
@@ -8711,14 +8694,13 @@
8711
8694
  */
8712
8695
  get domUpdater() {
8713
8696
  const identifiers = this.#conditionalContext.allDependentIdentifiers;
8714
- const render = () => this.#render();
8715
8697
  // Create an updater that handles the conditional rendering
8716
8698
  const updater = {
8717
8699
  get dependentIdentifiers() {
8718
8700
  return identifiers;
8719
8701
  },
8720
- applyToDOM() {
8721
- render();
8702
+ applyToDOM: () => {
8703
+ this.#render();
8722
8704
  }
8723
8705
  };
8724
8706
  return updater;
@@ -8854,14 +8836,8 @@
8854
8836
  */
8855
8837
  #cloneTemplate() {
8856
8838
  // Clone the original element
8857
- let clone;
8858
- if (this.vNode.directiveManager?.componentDirective) {
8859
- clone = this.vNode.directiveManager.componentDirective.cloneNode();
8860
- }
8861
- else {
8862
- const element = this.#vNode.node;
8863
- clone = element.cloneNode(true);
8864
- }
8839
+ const element = this.#vNode.node;
8840
+ const clone = element.cloneNode(true);
8865
8841
  // Create a new VNode for the cloned element
8866
8842
  const vNode = new VNode({
8867
8843
  node: clone,
@@ -9058,14 +9034,13 @@
9058
9034
  */
9059
9035
  get domUpdater() {
9060
9036
  const identifiers = this.#dependentIdentifiers ?? [];
9061
- const render = () => this.#render();
9062
9037
  // Create and return the DOM updater
9063
9038
  const updater = {
9064
9039
  get dependentIdentifiers() {
9065
9040
  return identifiers;
9066
9041
  },
9067
- applyToDOM() {
9068
- render();
9042
+ applyToDOM: () => {
9043
+ this.#render();
9069
9044
  }
9070
9045
  };
9071
9046
  return updater;
@@ -9297,14 +9272,8 @@
9297
9272
  */
9298
9273
  #cloneTemplate(context) {
9299
9274
  // Clone the original element
9300
- let clone;
9301
- if (this.vNode.directiveManager?.componentDirective) {
9302
- clone = this.vNode.directiveManager.componentDirective.cloneNode();
9303
- }
9304
- else {
9305
- const element = this.#vNode.node;
9306
- clone = element.cloneNode(true);
9307
- }
9275
+ const element = this.#vNode.node;
9276
+ const clone = element.cloneNode(true);
9308
9277
  // Prepare identifiers for the item
9309
9278
  this.#itemName;
9310
9279
  this.#indexName;
@@ -9700,14 +9669,13 @@
9700
9669
  */
9701
9670
  get domUpdater() {
9702
9671
  const identifiers = this.#dependentIdentifiers ?? [];
9703
- const render = () => this.#render();
9704
9672
  // Create and return the DOM updater
9705
9673
  const updater = {
9706
9674
  get dependentIdentifiers() {
9707
9675
  return identifiers;
9708
9676
  },
9709
- applyToDOM() {
9710
- render();
9677
+ applyToDOM: () => {
9678
+ this.#render();
9711
9679
  }
9712
9680
  };
9713
9681
  return updater;