[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:
Géry Debongnie
2019-04-14 10:44:29 +02:00
parent d7bed96667
commit 3733734ae5
3 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -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
View File
@@ -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][] = [];
+4 -4
View File
@@ -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 {