From 573135860758f16ec9c713946b30799df02d5798 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 5 Nov 2019 08:47:19 +0100 Subject: [PATCH] [IMP] component: expose scheduler instance Closes #433 --- src/component/component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/component/component.ts b/src/component/component.ts index 20a29018..d6d5120a 100644 --- a/src/component/component.ts +++ b/src/component/component.ts @@ -4,7 +4,7 @@ import { h, patch, VNode } from "../vdom/index"; import "./directive"; import { Fiber } from "./fiber"; import "./props_validation"; -import { scheduler } from "./scheduler"; +import { Scheduler, scheduler } from "./scheduler"; /** * Owl Component System @@ -88,6 +88,8 @@ export class Component { static props?: any; static defaultProps?: any; static env: any = {}; + // expose scheduler s.t. it can be mocked for testing purposes + static scheduler: Scheduler = scheduler; /** * The `el` is the root element of the component. Note that it could be null: @@ -287,7 +289,9 @@ export class Component { return; } if (!(target instanceof HTMLElement)) { - let message = `Component '${this.constructor.name}' cannot be mounted: the target is not a valid DOM node.`; + let message = `Component '${ + this.constructor.name + }' cannot be mounted: the target is not a valid DOM node.`; message += `\nMaybe the DOM is not ready yet? (in that case, you can use owl.utils.whenReady)`; throw new Error(message); }