mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: prevent rendering if not mounted
This commit is contained in:
+1
-1
@@ -238,7 +238,7 @@ export class Component<
|
|||||||
}
|
}
|
||||||
|
|
||||||
async render(force: boolean = false, patchQueue?: any[]): Promise<void> {
|
async render(force: boolean = false, patchQueue?: any[]): Promise<void> {
|
||||||
if (this.__owl__.isDestroyed) {
|
if (!this.__owl__.isMounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const shouldCallPatchHooks: boolean = !patchQueue;
|
const shouldCallPatchHooks: boolean = !patchQueue;
|
||||||
|
|||||||
+12
-1
@@ -87,6 +87,16 @@ describe("basic widget properties", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("can be clicked on and updated", async () => {
|
test("can be clicked on and updated", async () => {
|
||||||
|
const counter = new Counter(env);
|
||||||
|
await counter.mount(fixture);
|
||||||
|
expect(fixture.innerHTML).toBe("<div>0<button>Inc</button></div>");
|
||||||
|
const button = (<HTMLElement>counter.el).getElementsByTagName("button")[0];
|
||||||
|
await button.click();
|
||||||
|
await nextTick();
|
||||||
|
expect(fixture.innerHTML).toBe("<div>1<button>Inc</button></div>");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("cannot be clicked on and updated if not in DOM", async () => {
|
||||||
const counter = new Counter(env);
|
const counter = new Counter(env);
|
||||||
const target = document.createElement("div");
|
const target = document.createElement("div");
|
||||||
await counter.mount(target);
|
await counter.mount(target);
|
||||||
@@ -94,7 +104,8 @@ describe("basic widget properties", () => {
|
|||||||
const button = (<HTMLElement>counter.el).getElementsByTagName("button")[0];
|
const button = (<HTMLElement>counter.el).getElementsByTagName("button")[0];
|
||||||
await button.click();
|
await button.click();
|
||||||
await nextTick();
|
await nextTick();
|
||||||
expect(target.innerHTML).toBe("<div>1<button>Inc</button></div>");
|
expect(target.innerHTML).toBe("<div>0<button>Inc</button></div>");
|
||||||
|
expect(counter.state.counter).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("widget style and classname", async () => {
|
test("widget style and classname", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user