mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[REF] component: rename t-keep-alive to t-keepalive
This is useful to preserve the following nice property: when we have an attribute t-something-someotherthing, we can get the directive name by removing 't-' at the front, and splitting on '-'.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<div t-name="web.web_client" class="o_web_client">
|
<div t-name="web.web_client" class="o_web_client">
|
||||||
<t t-widget="Navbar" t-props="{inHome:state.inHome,app:state.currentApp}" />
|
<t t-widget="Navbar" t-props="{inHome:state.inHome,app:state.currentApp}" />
|
||||||
<t t-widget="HomeMenu" t-if="state.inHome" t-keep-alive="1" t-props="{menuInfo:props.menuInfo}" />
|
<t t-widget="HomeMenu" t-if="state.inHome" t-keepalive="1" t-props="{menuInfo:props.menuInfo}" />
|
||||||
<div class="o_content" t-att-class="state.inHome ? 'o_hidden' : ''" t-ref="'content'"/>
|
<div class="o_content" t-att-class="state.inHome ? 'o_hidden' : ''" t-ref="'content'"/>
|
||||||
<div class="o_notification_container">
|
<div class="o_notification_container">
|
||||||
<t t-foreach="state.notifications" t-as="notif">
|
<t t-foreach="state.notifications" t-as="notif">
|
||||||
|
|||||||
+2
-2
@@ -195,7 +195,7 @@ export class QWeb {
|
|||||||
attf: 1,
|
attf: 1,
|
||||||
props: 1,
|
props: 1,
|
||||||
key: 1,
|
key: 1,
|
||||||
keep: 1 // todo: rename keep-alive to keepalive
|
keepalive: 1
|
||||||
};
|
};
|
||||||
[
|
[
|
||||||
forEachDirective,
|
forEachDirective,
|
||||||
@@ -940,7 +940,7 @@ const widgetDirective: Directive = {
|
|||||||
ctx.addLine("//WIDGET");
|
ctx.addLine("//WIDGET");
|
||||||
ctx.rootContext.shouldDefineOwner = true;
|
ctx.rootContext.shouldDefineOwner = true;
|
||||||
let props = node.getAttribute("t-props");
|
let props = node.getAttribute("t-props");
|
||||||
let keepAlive = node.getAttribute("t-keep-alive") ? true : false;
|
let keepAlive = node.getAttribute("t-keepalive") ? true : false;
|
||||||
|
|
||||||
// t-on- events...
|
// t-on- events...
|
||||||
const events: [string, string][] = [];
|
const events: [string, string][] = [];
|
||||||
|
|||||||
@@ -739,10 +739,10 @@ describe("composition", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("sub widgets with t-keep-alive are not destroyed if no longer in dom", async () => {
|
test("sub widgets with t-keepalive are not destroyed if no longer in dom", async () => {
|
||||||
class ParentWidget extends Widget {
|
class ParentWidget extends Widget {
|
||||||
state = { ok: true };
|
state = { ok: true };
|
||||||
inlineTemplate = `<div><t t-if="state.ok"><t t-widget="counter" t-keep-alive="1"/></t></div>`;
|
inlineTemplate = `<div><t t-if="state.ok"><t t-widget="counter" t-keepalive="1"/></t></div>`;
|
||||||
widgets = { counter: Counter };
|
widgets = { counter: Counter };
|
||||||
}
|
}
|
||||||
const widget = new ParentWidget(env);
|
const widget = new ParentWidget(env);
|
||||||
@@ -765,10 +765,10 @@ describe("composition", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("sub widgets dom state with t-keep-alive is preserved", async () => {
|
test("sub widgets dom state with t-keepalive is preserved", async () => {
|
||||||
class ParentWidget extends Widget {
|
class ParentWidget extends Widget {
|
||||||
state = { ok: true };
|
state = { ok: true };
|
||||||
inlineTemplate = `<div><t t-if="state.ok"><t t-widget="InputWidget" t-keep-alive="1"/></t></div>`;
|
inlineTemplate = `<div><t t-if="state.ok"><t t-widget="InputWidget" t-keepalive="1"/></t></div>`;
|
||||||
widgets = { InputWidget };
|
widgets = { InputWidget };
|
||||||
}
|
}
|
||||||
class InputWidget extends Widget {
|
class InputWidget extends Widget {
|
||||||
|
|||||||
Reference in New Issue
Block a user