[FIX] component: allow fragments in method mount

It is now possible to mount components in fragments

closes #494
This commit is contained in:
Géry Debongnie
2019-11-22 14:49:37 +01:00
committed by aab-odoo
parent 7bb04185c7
commit 14db513f3b
3 changed files with 28 additions and 3 deletions
+2 -2
View File
@@ -281,12 +281,12 @@ export class Component<T extends Env, Props extends {}> {
*
* Note that a component can be mounted an unmounted several times
*/
async mount(target: HTMLElement): Promise<void> {
async mount(target: HTMLElement | DocumentFragment): Promise<void> {
const __owl__ = this.__owl__;
if (__owl__.isMounted) {
return Promise.resolve();
}
if (!(target instanceof HTMLElement)) {
if (!(target instanceof HTMLElement || target instanceof DocumentFragment)) {
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);