@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.
@@ -6956,14 +6956,13 @@ class VBindDirective {
6956
6956
  */
6957
6957
  get domUpdater() {
6958
6958
  const identifiers = this.#dependentIdentifiers ?? [];
6959
- const render = () => this.#render();
6960
6959
  // Create an updater that handles the attribute binding
6961
6960
  const updater = {
6962
6961
  get dependentIdentifiers() {
6963
6962
  return identifiers;
6964
6963
  },
6965
- applyToDOM() {
6966
- render();
6964
+ applyToDOM: () => {
6965
+ this.#render();
6967
6966
  }
6968
6967
  };
6969
6968
  return updater;
@@ -7227,13 +7226,9 @@ class VComponentDirective {
7227
7226
  */
7228
7227
  #componentId;
7229
7228
  /**
7230
- * The child application instance for the component.
7231
- */
7232
- #childApp;
7233
- /**
7234
- * Whether the component has been activated.
7229
+ * The application instance for the component.
7235
7230
  */
7236
- #isActivated = false;
7231
+ #componentApp;
7237
7232
  constructor(context) {
7238
7233
  this.#vNode = context.vNode;
7239
7234
  this.#componentId = context.attribute.value.trim();
@@ -7256,7 +7251,7 @@ class VComponentDirective {
7256
7251
  * @inheritdoc
7257
7252
  */
7258
7253
  get needsAnchor() {
7259
- return false;
7254
+ return true;
7260
7255
  }
7261
7256
  /**
7262
7257
  * @inheritdoc
@@ -7274,9 +7269,7 @@ class VComponentDirective {
7274
7269
  return [];
7275
7270
  },
7276
7271
  applyToDOM: () => {
7277
- if (!this.#isActivated) {
7278
- this.#renderComponent();
7279
- }
7272
+ this.#render();
7280
7273
  }
7281
7274
  };
7282
7275
  return updater;
@@ -7285,7 +7278,7 @@ class VComponentDirective {
7285
7278
  * @inheritdoc
7286
7279
  */
7287
7280
  get templatize() {
7288
- return false;
7281
+ return true;
7289
7282
  }
7290
7283
  /**
7291
7284
  * @inheritdoc
@@ -7321,7 +7314,7 @@ class VComponentDirective {
7321
7314
  * @inheritdoc
7322
7315
  */
7323
7316
  get onUnmount() {
7324
- return () => this.#cleanupComponent();
7317
+ return undefined;
7325
7318
  }
7326
7319
  /**
7327
7320
  * @inheritdoc
@@ -7329,7 +7322,7 @@ class VComponentDirective {
7329
7322
  get onUnmounted() {
7330
7323
  return undefined;
7331
7324
  }
7332
- cloneNode() {
7325
+ #cloneNode() {
7333
7326
  // Get component definition from the application's component registry
7334
7327
  const component = this.#vNode.vApplication.componentRegistry.get(this.#componentId);
7335
7328
  if (!component) {
@@ -7356,12 +7349,29 @@ class VComponentDirective {
7356
7349
  * @inheritdoc
7357
7350
  */
7358
7351
  destroy() {
7359
- this.#cleanupComponent();
7352
+ if (!this.#componentApp) {
7353
+ // Not rendered, no action needed
7354
+ return;
7355
+ }
7356
+ // Destroy component application first (calls @unmount hooks while DOM is still accessible)
7357
+ this.#componentApp.unmount();
7358
+ // Then remove from DOM
7359
+ const componentVNode = this.#componentApp.rootVNode;
7360
+ if (componentVNode?.node.parentNode) {
7361
+ componentVNode.node.parentNode.removeChild(componentVNode.node);
7362
+ }
7363
+ this.#componentApp = undefined;
7360
7364
  }
7361
7365
  /**
7362
7366
  * Renders the component.
7363
7367
  */
7364
- #renderComponent() {
7368
+ #render() {
7369
+ if (this.#componentApp) {
7370
+ // Already rendered, no action needed
7371
+ return;
7372
+ }
7373
+ const clone = this.#cloneNode();
7374
+ this.#vNode.anchorNode?.parentNode?.insertBefore(clone, this.#vNode.anchorNode.nextSibling);
7365
7375
  // Get properties from :options or :options.component directive
7366
7376
  let properties = {};
7367
7377
  const optionsDirective = this.#vNode.directiveManager?.optionsDirective('component');
@@ -7385,19 +7395,8 @@ class VComponentDirective {
7385
7395
  // Create component instance
7386
7396
  const instance = component.createInstance(properties);
7387
7397
  // Create and mount child application using the parent application's registries
7388
- this.#childApp = this.#vNode.vApplication.createChildApp(instance);
7389
- this.#childApp.mount(this.#vNode.node);
7390
- this.#isActivated = true;
7391
- }
7392
- /**
7393
- * Cleans up the component.
7394
- */
7395
- #cleanupComponent() {
7396
- if (this.#childApp) {
7397
- this.#childApp.unmount();
7398
- this.#childApp = undefined;
7399
- }
7400
- this.#isActivated = false;
7398
+ this.#componentApp = this.#vNode.vApplication.createChildApp(instance);
7399
+ this.#componentApp.mount(clone);
7401
7400
  }
7402
7401
  }
7403
7402
 
@@ -7732,11 +7731,6 @@ class VDirectiveManager {
7732
7731
  * The keys are directive names (e.g., 'options', 'options.intersection').
7733
7732
  */
7734
7733
  #optionsDirectives = {};
7735
- /**
7736
- * The v-component directive associated with this node, if any.
7737
- * This may be undefined if there is no v-component directive.
7738
- */
7739
- #componentDirective;
7740
7734
  constructor(vNode) {
7741
7735
  // Directives can only be associated with element nodes
7742
7736
  if (vNode.nodeType !== Node.ELEMENT_NODE) {
@@ -7794,13 +7788,6 @@ class VDirectiveManager {
7794
7788
  get keyDirective() {
7795
7789
  return this.#keyDirective;
7796
7790
  }
7797
- /**
7798
- * Gets the v-component directive associated with this node, if any.
7799
- * This may be undefined if there is no v-component directive.
7800
- */
7801
- get componentDirective() {
7802
- return this.#componentDirective;
7803
- }
7804
7791
  /**
7805
7792
  * Gets the VBindDirective for options specific to the given directive name.
7806
7793
  * Searches in order: `:options.{directive}` -> `:options`
@@ -7890,10 +7877,6 @@ class VDirectiveManager {
7890
7877
  this.#optionsDirectives[attrName] = bindDirective;
7891
7878
  }
7892
7879
  }
7893
- // If this is a v-component directive, store it separately
7894
- if (directive.name === StandardDirectiveName.V_COMPONENT) {
7895
- this.#componentDirective = directive;
7896
- }
7897
7880
  }
7898
7881
  }
7899
7882
  // Sort directives by priority: v-for > v-if > v-else-if > v-else > v-show > others
@@ -8705,14 +8688,13 @@ class VConditionalDirective {
8705
8688
  */
8706
8689
  get domUpdater() {
8707
8690
  const identifiers = this.#conditionalContext.allDependentIdentifiers;
8708
- const render = () => this.#render();
8709
8691
  // Create an updater that handles the conditional rendering
8710
8692
  const updater = {
8711
8693
  get dependentIdentifiers() {
8712
8694
  return identifiers;
8713
8695
  },
8714
- applyToDOM() {
8715
- render();
8696
+ applyToDOM: () => {
8697
+ this.#render();
8716
8698
  }
8717
8699
  };
8718
8700
  return updater;
@@ -8848,14 +8830,8 @@ class VConditionalDirective {
8848
8830
  */
8849
8831
  #cloneTemplate() {
8850
8832
  // Clone the original element
8851
- let clone;
8852
- if (this.vNode.directiveManager?.componentDirective) {
8853
- clone = this.vNode.directiveManager.componentDirective.cloneNode();
8854
- }
8855
- else {
8856
- const element = this.#vNode.node;
8857
- clone = element.cloneNode(true);
8858
- }
8833
+ const element = this.#vNode.node;
8834
+ const clone = element.cloneNode(true);
8859
8835
  // Create a new VNode for the cloned element
8860
8836
  const vNode = new VNode({
8861
8837
  node: clone,
@@ -9052,14 +9028,13 @@ class VForDirective {
9052
9028
  */
9053
9029
  get domUpdater() {
9054
9030
  const identifiers = this.#dependentIdentifiers ?? [];
9055
- const render = () => this.#render();
9056
9031
  // Create and return the DOM updater
9057
9032
  const updater = {
9058
9033
  get dependentIdentifiers() {
9059
9034
  return identifiers;
9060
9035
  },
9061
- applyToDOM() {
9062
- render();
9036
+ applyToDOM: () => {
9037
+ this.#render();
9063
9038
  }
9064
9039
  };
9065
9040
  return updater;
@@ -9291,14 +9266,8 @@ class VForDirective {
9291
9266
  */
9292
9267
  #cloneTemplate(context) {
9293
9268
  // Clone the original element
9294
- let clone;
9295
- if (this.vNode.directiveManager?.componentDirective) {
9296
- clone = this.vNode.directiveManager.componentDirective.cloneNode();
9297
- }
9298
- else {
9299
- const element = this.#vNode.node;
9300
- clone = element.cloneNode(true);
9301
- }
9269
+ const element = this.#vNode.node;
9270
+ const clone = element.cloneNode(true);
9302
9271
  // Prepare identifiers for the item
9303
9272
  this.#itemName;
9304
9273
  this.#indexName;
@@ -9694,14 +9663,13 @@ class VModelDirective {
9694
9663
  */
9695
9664
  get domUpdater() {
9696
9665
  const identifiers = this.#dependentIdentifiers ?? [];
9697
- const render = () => this.#render();
9698
9666
  // Create and return the DOM updater
9699
9667
  const updater = {
9700
9668
  get dependentIdentifiers() {
9701
9669
  return identifiers;
9702
9670
  },
9703
- applyToDOM() {
9704
- render();
9671
+ applyToDOM: () => {
9672
+ this.#render();
9705
9673
  }
9706
9674
  };
9707
9675
  return updater;