mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[REF] allow external code to override validateTarget
This commit is contained in:
+3
-1
@@ -28,6 +28,8 @@ export class App<
|
|||||||
P = any,
|
P = any,
|
||||||
E = any
|
E = any
|
||||||
> extends TemplateSet {
|
> extends TemplateSet {
|
||||||
|
static validateTarget = validateTarget;
|
||||||
|
|
||||||
Root: ComponentConstructor<P, E>;
|
Root: ComponentConstructor<P, E>;
|
||||||
props: P;
|
props: P;
|
||||||
env: E;
|
env: E;
|
||||||
@@ -49,7 +51,7 @@ export class App<
|
|||||||
}
|
}
|
||||||
|
|
||||||
mount(target: HTMLElement, options?: MountOptions): Promise<Component<P, E> & InstanceType<T>> {
|
mount(target: HTMLElement, options?: MountOptions): Promise<Component<P, E> & InstanceType<T>> {
|
||||||
validateTarget(target);
|
App.validateTarget(target);
|
||||||
const node = this.makeNode(this.Root, this.props);
|
const node = this.makeNode(this.Root, this.props);
|
||||||
const prom = this.mountNode(node, target, options);
|
const prom = this.mountNode(node, target, options);
|
||||||
this.root = node;
|
this.root = node;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { BDom, mount } from "../blockdom";
|
import { BDom, mount } from "../blockdom";
|
||||||
import { validateTarget } from "../utils";
|
|
||||||
import type { ComponentNode } from "./component_node";
|
import type { ComponentNode } from "./component_node";
|
||||||
import { fibersInError, handleError } from "./error_handling";
|
import { fibersInError, handleError } from "./error_handling";
|
||||||
import { STATUS } from "./status";
|
import { STATUS } from "./status";
|
||||||
@@ -159,8 +158,8 @@ export class MountFiber extends RootFiber {
|
|||||||
complete() {
|
complete() {
|
||||||
let current: Fiber | undefined = this;
|
let current: Fiber | undefined = this;
|
||||||
try {
|
try {
|
||||||
validateTarget(this.target);
|
|
||||||
const node = this.node;
|
const node = this.node;
|
||||||
|
(node.app.constructor as any).validateTarget(this.target);
|
||||||
if (node.bdom) {
|
if (node.bdom) {
|
||||||
// this is a complicated situation: if we mount a fiber with an existing
|
// this is a complicated situation: if we mount a fiber with an existing
|
||||||
// bdom, this means that this same fiber was already completed, mounted,
|
// bdom, this means that this same fiber was already completed, mounted,
|
||||||
|
|||||||
@@ -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
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||||
|
|||||||
Reference in New Issue
Block a user