[IMP] component: can trigger event handlers even if unmounted

From the beginning, Owl was designed to only call event handler on
components that are mounted in the DOM.  The main benefit is that if a
component is destroyed, we are guaranteed to not execute any useless (or
potentially dangerous code).

However, there is one downside: if a component tree is being mounted,
and a child component trigger an event in its mounted hook, then it
cannot be caught by the parent, since the parent is technically not yet
mounted.

This may not be a good situation, but the point is that Owl
unnecessarily prevent the handler to be called.

We can fix this issue by simply checking if the component is not destroyed
instead of checking that it is mounted.

closes #809
This commit is contained in:
Géry Debongnie
2021-02-03 13:53:14 +01:00
committed by aab-odoo
parent af426aa902
commit 398f9f4e53
7 changed files with 77 additions and 57 deletions
+2 -2
View File
@@ -663,7 +663,7 @@ function makeStore() {
function setup() {
owl.config.mode = "dev";
const env = {store: makeStore()};
const env = { store: makeStore() };
mount(App, { target: document.body, env });
}
```
@@ -939,7 +939,7 @@ For reference, here is the final code:
function setup() {
owl.config.mode = "dev";
const env = {store: makeStore()};
const env = { store: makeStore() };
mount(App, { target: document.body, env });
}