diff --git a/src/app/app.ts b/src/app/app.ts index b05143fd..38d753bd 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -28,6 +28,8 @@ export class App< P = any, E = any > extends TemplateSet { + static validateTarget = validateTarget; + Root: ComponentConstructor; props: P; env: E; @@ -49,7 +51,7 @@ export class App< } mount(target: HTMLElement, options?: MountOptions): Promise & InstanceType> { - validateTarget(target); + App.validateTarget(target); const node = this.makeNode(this.Root, this.props); const prom = this.mountNode(node, target, options); this.root = node; diff --git a/src/component/fibers.ts b/src/component/fibers.ts index 8c9ce42c..b944c4fd 100644 --- a/src/component/fibers.ts +++ b/src/component/fibers.ts @@ -1,5 +1,4 @@ import { BDom, mount } from "../blockdom"; -import { validateTarget } from "../utils"; import type { ComponentNode } from "./component_node"; import { fibersInError, handleError } from "./error_handling"; import { STATUS } from "./status"; @@ -159,8 +158,8 @@ export class MountFiber extends RootFiber { complete() { let current: Fiber | undefined = this; try { - validateTarget(this.target); const node = this.node; + (node.app.constructor as any).validateTarget(this.target); if (node.bdom) { // this is a complicated situation: if we mount a fiber with an existing // bdom, this means that this same fiber was already completed, mounted, diff --git a/tests/components/__snapshots__/basics.test.ts.snap b/tests/components/__snapshots__/basics.test.ts.snap index 07c1c560..5d05da30 100644 --- a/tests/components/__snapshots__/basics.test.ts.snap +++ b/tests/components/__snapshots__/basics.test.ts.snap @@ -81,7 +81,7 @@ exports[`basics a class component inside a class component, no external dom 2`] }" `; -exports[`basics a component cannot be mounted in a detached node (even if node is detached later 1`] = ` +exports[`basics a component cannot be mounted in a detached node (even if node is detached later) 1`] = ` "function anonymous(bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;