[FIX] components: only call handlers if component is mounted

This commit is contained in:
Géry Debongnie
2022-01-17 14:13:32 +01:00
committed by Aaron Bohy
parent 7711733a23
commit 42a140a8e3
4 changed files with 114 additions and 8 deletions
+5 -1
View File
@@ -1,4 +1,5 @@
import { filterOutModifiersFromData } from "../blockdom/config";
import { STATUS } from "./status";
export const mainEventHandler = (data: any, ev: Event, currentTarget?: EventTarget | null) => {
const { data: _data, modifiers } = filterOutModifiersFromData(data);
@@ -30,7 +31,10 @@ export const mainEventHandler = (data: any, ev: Event, currentTarget?: EventTarg
// We check this rather than data[0] being truthy (or typeof function) so that it crashes
// as expected when there is a handler expression that evaluates to a falsy value
if (Object.hasOwnProperty.call(data, 0)) {
data[0].call(data[1] ? data[1].__owl__.component : null, ev);
let node = data[1] ? data[1].__owl__ : null;
if (node ? node.status === STATUS.MOUNTED : true) {
data[0].call(node ? node.component : null, ev);
}
}
return stopped;
};