@mintjamsinc/ichigojs 0.1.14 → 0.1.16

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();
@@ -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,6 +7322,11 @@ class VComponentDirective {
7329
7322
  get onUnmounted() {
7330
7323
  return undefined;
7331
7324
  }
7325
+ /**
7326
+ * Clones the component's template and returns the root element.
7327
+ * @returns The cloned root HTMLElement of the component.
7328
+ * @throws Error if the component or its template is not found.
7329
+ */
7332
7330
  cloneNode() {
7333
7331
  // Get component definition from the application's component registry
7334
7332
  const component = this.#vNode.vApplication.componentRegistry.get(this.#componentId);
@@ -7356,12 +7354,27 @@ class VComponentDirective {
7356
7354
  * @inheritdoc
7357
7355
  */
7358
7356
  destroy() {
7359
- this.#cleanupComponent();
7357
+ if (!this.#componentApp) {
7358
+ // Not rendered, no action needed
7359
+ return;
7360
+ }
7361
+ // Destroy component application first (calls @unmount hooks while DOM is still accessible)
7362
+ this.#componentApp.unmount();
7363
+ // Then remove from DOM
7364
+ const componentVNode = this.#componentApp.rootVNode;
7365
+ if (componentVNode?.node.parentNode) {
7366
+ componentVNode.node.parentNode.removeChild(componentVNode.node);
7367
+ }
7368
+ this.#componentApp = undefined;
7360
7369
  }
7361
7370
  /**
7362
7371
  * Renders the component.
7363
7372
  */
7364
- #renderComponent() {
7373
+ #render() {
7374
+ if (this.#componentApp) {
7375
+ // Already rendered, no action needed
7376
+ return;
7377
+ }
7365
7378
  // Get properties from :options or :options.component directive
7366
7379
  let properties = {};
7367
7380
  const optionsDirective = this.#vNode.directiveManager?.optionsDirective('component');
@@ -7385,19 +7398,8 @@ class VComponentDirective {
7385
7398
  // Create component instance
7386
7399
  const instance = component.createInstance(properties);
7387
7400
  // 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;
7401
+ this.#componentApp = this.#vNode.vApplication.createChildApp(instance);
7402
+ this.#componentApp.mount(this.#vNode.node);
7401
7403
  }
7402
7404
  }
7403
7405
 
@@ -8705,14 +8707,13 @@ class VConditionalDirective {
8705
8707
  */
8706
8708
  get domUpdater() {
8707
8709
  const identifiers = this.#conditionalContext.allDependentIdentifiers;
8708
- const render = () => this.#render();
8709
8710
  // Create an updater that handles the conditional rendering
8710
8711
  const updater = {
8711
8712
  get dependentIdentifiers() {
8712
8713
  return identifiers;
8713
8714
  },
8714
- applyToDOM() {
8715
- render();
8715
+ applyToDOM: () => {
8716
+ this.#render();
8716
8717
  }
8717
8718
  };
8718
8719
  return updater;
@@ -9052,14 +9053,13 @@ class VForDirective {
9052
9053
  */
9053
9054
  get domUpdater() {
9054
9055
  const identifiers = this.#dependentIdentifiers ?? [];
9055
- const render = () => this.#render();
9056
9056
  // Create and return the DOM updater
9057
9057
  const updater = {
9058
9058
  get dependentIdentifiers() {
9059
9059
  return identifiers;
9060
9060
  },
9061
- applyToDOM() {
9062
- render();
9061
+ applyToDOM: () => {
9062
+ this.#render();
9063
9063
  }
9064
9064
  };
9065
9065
  return updater;
@@ -9694,14 +9694,13 @@ class VModelDirective {
9694
9694
  */
9695
9695
  get domUpdater() {
9696
9696
  const identifiers = this.#dependentIdentifiers ?? [];
9697
- const render = () => this.#render();
9698
9697
  // Create and return the DOM updater
9699
9698
  const updater = {
9700
9699
  get dependentIdentifiers() {
9701
9700
  return identifiers;
9702
9701
  },
9703
- applyToDOM() {
9704
- render();
9702
+ applyToDOM: () => {
9703
+ this.#render();
9705
9704
  }
9706
9705
  };
9707
9706
  return updater;