diff --git a/src/qweb/base_directives.ts b/src/qweb/base_directives.ts
index 16a17b39..92965d25 100644
--- a/src/qweb/base_directives.ts
+++ b/src/qweb/base_directives.ts
@@ -55,6 +55,7 @@ function compileValueNode(value: any, node: Element, qweb: QWeb, ctx: Context) {
ctx.rootContext.rootNode = nodeID;
ctx.rootContext.parentTextNode = nodeID;
ctx.addLine(`var vn${nodeID} = {text: ${exprID}};`);
+ ctx.addLine(`result = vn${nodeID}`);
}
} else {
let fragID = ctx.generateID();
diff --git a/src/qweb/context.ts b/src/qweb/context.ts
index b4370af3..872c929f 100644
--- a/src/qweb/context.ts
+++ b/src/qweb/context.ts
@@ -19,7 +19,7 @@ export class Context {
shouldDefineParent: boolean = false;
shouldDefineQWeb: boolean = false;
shouldDefineUtils: boolean = false;
- shouldDefineResult: boolean = false;
+ shouldDefineResult: boolean = true;
shouldProtectContext: boolean = false;
shouldTrackScope: boolean = false;
inLoop: boolean = false;
@@ -93,6 +93,9 @@ export class Context {
if (!this.rootContext.rootNode) {
this.rootContext.rootNode = node;
}
+ if (!this.parentNode) {
+ this.addLine(`result = vn${node};`);
+ }
return this.subContext("parentNode", node);
}
diff --git a/src/qweb/qweb.ts b/src/qweb/qweb.ts
index c6ae525f..e3dd7b0c 100644
--- a/src/qweb/qweb.ts
+++ b/src/qweb/qweb.ts
@@ -333,6 +333,7 @@ export class QWeb extends EventBus {
ctx.parentNode = parentContext.parentNode!;
ctx.allowMultipleRoots = true;
ctx.hasParentWidget = true;
+ ctx.shouldDefineResult = false;
ctx.addLine(`let c${ctx.parentNode} = extra.parentNode;`);
for (let v in parentContext.variables) {
@@ -405,6 +406,7 @@ export class QWeb extends EventBus {
// template rendering.
let nodeID = ctx.generateID();
ctx.addLine(`var vn${nodeID} = {text: \`${text}\`};`);
+ ctx.addLine(`result = vn${nodeID};`);
ctx.rootContext.rootNode = nodeID;
ctx.rootContext.parentTextNode = nodeID;
}
diff --git a/tests/__snapshots__/animations.test.ts.snap b/tests/__snapshots__/animations.test.ts.snap
index 3e88c6a0..9369df43 100644
--- a/tests/__snapshots__/animations.test.ts.snap
+++ b/tests/__snapshots__/animations.test.ts.snap
@@ -7,9 +7,11 @@ exports[`animations t-transition combined with component 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -40,7 +42,7 @@ exports[`animations t-transition combined with component 1`] = `
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -51,9 +53,11 @@ exports[`animations t-transition combined with t-component and t-if 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['state'].display) {
//COMPONENT
let def3;
@@ -86,7 +90,7 @@ exports[`animations t-transition combined with t-component and t-if 1`] = `
}
extra.promises.push(def3);
}
- return vn1;
+ return result;
}"
`;
@@ -94,9 +98,11 @@ exports[`animations t-transition with no delay/duration 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('span', p1, c1);
+ result = vn1;
p1.hook = {
insert: vn => {
utils.transitionInsert(vn, 'jupiler');
@@ -106,7 +112,7 @@ exports[`animations t-transition with no delay/duration 1`] = `
},
};
c1.push({text: \`blue\`});
- return vn1;
+ return result;
}"
`;
@@ -114,9 +120,11 @@ exports[`animations t-transition, on a simple node (insert) 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('span', p1, c1);
+ result = vn1;
p1.hook = {
insert: vn => {
utils.transitionInsert(vn, 'chimay');
@@ -126,6 +134,6 @@ exports[`animations t-transition, on a simple node (insert) 1`] = `
},
};
c1.push({text: \`blue\`});
- return vn1;
+ return result;
}"
`;
diff --git a/tests/component/__snapshots__/component.test.ts.snap b/tests/component/__snapshots__/component.test.ts.snap
index 11f6f42d..0ec816db 100644
--- a/tests/component/__snapshots__/component.test.ts.snap
+++ b/tests/component/__snapshots__/component.test.ts.snap
@@ -7,9 +7,11 @@ exports[`async rendering delayed component with t-asyncroot directive 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('button', p2, c2);
c1.push(vn2);
@@ -78,7 +80,7 @@ exports[`async rendering delayed component with t-asyncroot directive 1`] = `
def10 = def10.then(()=>{if (w11.__owl__.isDestroyed) {return};let pvnode=w11.__owl__.pvnode;c5[_9_index]=pvnode;});
}
def10.then(w11.__applyPatchQueue.bind(w11, patchQueue11));
- return vn1;
+ return result;
}"
`;
@@ -89,9 +91,11 @@ exports[`async rendering fast component with t-asyncroot directive 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('button', p2, c2);
c1.push(vn2);
@@ -160,7 +164,7 @@ exports[`async rendering fast component with t-asyncroot directive 1`] = `
def10 = def10.then(()=>{if (w11.__owl__.isDestroyed) {return};let pvnode=w11.__owl__.pvnode;c5[_9_index]=pvnode;});
}
extra.promises.push(def10);
- return vn1;
+ return result;
}"
`;
@@ -171,9 +175,11 @@ exports[`async rendering t-component with t-asyncroot directive: mixed re-render
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('button', p2, c2);
c1.push(vn2);
@@ -242,7 +248,7 @@ exports[`async rendering t-component with t-asyncroot directive: mixed re-render
def10 = def10.then(()=>{if (w11.__owl__.isDestroyed) {return};let pvnode=w11.__owl__.pvnode;c5[_9_index]=pvnode;});
}
def10.then(w11.__applyPatchQueue.bind(w11, patchQueue11));
- return vn1;
+ return result;
}"
`;
@@ -253,9 +259,11 @@ exports[`class and style attributes with t-component dynamic t-att-style is prop
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
const _5 = context['state'].style;
@@ -284,7 +292,7 @@ exports[`class and style attributes with t-component dynamic t-att-style is prop
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};w4.el.style=_5;let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -295,9 +303,11 @@ exports[`class and style attributes with t-component t-att-class is properly add
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
const ref5 = \`child\`;
@@ -329,7 +339,7 @@ exports[`class and style attributes with t-component t-att-class is properly add
}
w4.__owl__.classObj=_6;
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -337,12 +347,14 @@ exports[`class and style attributes with t-component t-att-class is properly add
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let _2 = {'c':true};
Object.assign(_2, utils.toObj({d:context['state'].d}))
let c3 = [], p3 = {key:3,class:_2};
var vn3 = h('span', p3, c3);
- return vn3;
+ result = vn3;
+ return result;
}"
`;
@@ -353,9 +365,11 @@ exports[`class and style attributes with t-component t-att-class is properly add
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
const ref5 = \`child\`;
@@ -387,7 +401,7 @@ exports[`class and style attributes with t-component t-att-class is properly add
}
w4.__owl__.classObj=_6;
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -395,12 +409,14 @@ exports[`class and style attributes with t-component t-att-class is properly add
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let _2 = {'c':true};
Object.assign(_2, utils.toObj(context['state'].d?'d':''))
let c3 = [], p3 = {key:3,class:_2};
var vn3 = h('span', p3, c3);
- return vn3;
+ result = vn3;
+ return result;
}"
`;
@@ -411,9 +427,11 @@ exports[`class and style attributes with t-component t-att-class is properly add
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let _5 = {a:context['state'].a,b:context['state'].b};
@@ -443,7 +461,7 @@ exports[`class and style attributes with t-component t-att-class is properly add
}
w4.__owl__.classObj=_5;
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -454,9 +472,11 @@ exports[`composition sub components dom state with t-keepalive is preserved 1`]
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['state'].ok) {
//COMPONENT
let def3;
@@ -486,7 +506,7 @@ exports[`composition sub components dom state with t-keepalive is preserved 1`]
}
extra.promises.push(def3);
}
- return vn1;
+ return result;
}"
`;
@@ -497,10 +517,12 @@ exports[`composition sub components with some state rendered in a loop 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['state'].numbers;
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -545,7 +567,7 @@ exports[`composition sub components with some state rendered in a loop 1`] = `
}
extra.promises.push(def6);
}
- return vn1;
+ return result;
}"
`;
@@ -556,9 +578,11 @@ exports[`composition t-component with dynamic value 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -586,7 +610,7 @@ exports[`composition t-component with dynamic value 1`] = `
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -597,9 +621,11 @@ exports[`composition t-component with dynamic value 2 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -627,7 +653,7 @@ exports[`composition t-component with dynamic value 2 1`] = `
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -638,9 +664,11 @@ exports[`lifecycle hooks willPatch/patched hook with t-keepalive 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['state'].flag) {
//COMPONENT
let def3;
@@ -670,7 +698,7 @@ exports[`lifecycle hooks willPatch/patched hook with t-keepalive 1`] = `
}
extra.promises.push(def3);
}
- return vn1;
+ return result;
}"
`;
@@ -681,9 +709,11 @@ exports[`other directives with t-component t-on with handler bound to argument 1
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -711,7 +741,7 @@ exports[`other directives with t-component t-on with handler bound to argument 1
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -722,9 +752,11 @@ exports[`other directives with t-component t-on with handler bound to empty obje
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -752,7 +784,7 @@ exports[`other directives with t-component t-on with handler bound to empty obje
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -763,9 +795,11 @@ exports[`other directives with t-component t-on with handler bound to empty obje
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -793,7 +827,7 @@ exports[`other directives with t-component t-on with handler bound to empty obje
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -804,9 +838,11 @@ exports[`other directives with t-component t-on with handler bound to object 1`]
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -834,7 +870,7 @@ exports[`other directives with t-component t-on with handler bound to object 1`]
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -845,9 +881,11 @@ exports[`other directives with t-component t-on with prevent and self modifiers
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -875,7 +913,7 @@ exports[`other directives with t-component t-on with prevent and self modifiers
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -886,9 +924,11 @@ exports[`other directives with t-component t-on with self and prevent modifiers
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -916,7 +956,7 @@ exports[`other directives with t-component t-on with self and prevent modifiers
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -927,9 +967,11 @@ exports[`other directives with t-component t-on with self modifier 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -957,7 +999,7 @@ exports[`other directives with t-component t-on with self modifier 1`] = `
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -968,9 +1010,11 @@ exports[`other directives with t-component t-on with stop and/or prevent modifie
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -998,7 +1042,7 @@ exports[`other directives with t-component t-on with stop and/or prevent modifie
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -1009,9 +1053,11 @@ exports[`random stuff/miscellaneous snapshotting compiled code 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let key5 = 'key' + 'somestring';
let def3;
@@ -1041,7 +1087,7 @@ exports[`random stuff/miscellaneous snapshotting compiled code 1`] = `
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -1052,10 +1098,12 @@ exports[`random stuff/miscellaneous t-on with handler bound to dynamic argument
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['props'].items;
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -1101,16 +1149,18 @@ exports[`random stuff/miscellaneous t-on with handler bound to dynamic argument
}
extra.promises.push(def6);
}
- return vn1;
+ return result;
}"
`;
exports[`t-model directive .lazy modifier 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('input', p2, c2);
c1.push(vn2);
@@ -1124,16 +1174,18 @@ exports[`t-model directive .lazy modifier 1`] = `
if (_4 || _4 === 0) {
c3.push({text: _4});
}
- return vn1;
+ return result;
}"
`;
exports[`t-model directive basic use, on an input 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('input', p2, c2);
c1.push(vn2);
@@ -1147,16 +1199,18 @@ exports[`t-model directive basic use, on an input 1`] = `
if (_4 || _4 === 0) {
c3.push({text: _4});
}
- return vn1;
+ return result;
}"
`;
exports[`t-model directive on a select 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('select', p2, c2);
c1.push(vn2);
@@ -1191,16 +1245,18 @@ exports[`t-model directive on a select 1`] = `
if (_10 || _10 === 0) {
c9.push({text: _10});
}
- return vn1;
+ return result;
}"
`;
exports[`t-model directive on a sub state key 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('input', p2, c2);
c1.push(vn2);
@@ -1214,16 +1270,18 @@ exports[`t-model directive on a sub state key 1`] = `
if (_4 || _4 === 0) {
c3.push({text: _4});
}
- return vn1;
+ return result;
}"
`;
exports[`t-model directive on an input type=radio 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 'radio';
var _3 = 'one';
var _4 = 'One';
@@ -1250,16 +1308,18 @@ exports[`t-model directive on an input type=radio 1`] = `
if (_11 || _11 === 0) {
c10.push({text: _11});
}
- return vn1;
+ return result;
}"
`;
exports[`t-model directive on an input, type=checkbox 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 'checkbox';
let c3 = [], p3 = {key:3,attrs:{type: _2},on:{}};
var vn3 = h('input', p3, c3);
@@ -1276,7 +1336,7 @@ exports[`t-model directive on an input, type=checkbox 1`] = `
else {
c4.push({text: \`no\`});
}
- return vn1;
+ return result;
}"
`;
@@ -1287,9 +1347,11 @@ exports[`t-slot directive can define and call slots 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -1318,7 +1380,7 @@ exports[`t-slot directive can define and call slots 1`] = `
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
@@ -1326,9 +1388,11 @@ exports[`t-slot directive can define and call slots 2`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('div', p2, c2);
c1.push(vn2);
@@ -1343,7 +1407,7 @@ exports[`t-slot directive can define and call slots 2`] = `
if (slot5) {
slot5.call(this, context.__owl__.parent, Object.assign({}, extra, {parentNode: c4, vars: extra.vars, parent: owner}));
}
- return vn1;
+ return result;
}"
`;
@@ -1478,15 +1542,17 @@ exports[`t-slot directive slots are rendered with proper context, part 2 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
var _1 = context['props'].to;
let c2 = [], p2 = {key:2,attrs:{href: _1}};
var vn2 = h('a', p2, c2);
+ result = vn2;
const slot3 = this.slots[context.__owl__.slotId + '_' + 'default'];
if (slot3) {
slot3.call(this, context.__owl__.parent, Object.assign({}, extra, {parentNode: c2, vars: extra.vars, parent: owner}));
}
- return vn2;
+ return result;
}"
`;
@@ -1497,11 +1563,13 @@ exports[`t-slot directive slots are rendered with proper context, part 2 2`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
context = Object.create(context);
const scope = Object.create(null);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('u', p2, c2);
c1.push(vn2);
@@ -1558,7 +1626,7 @@ exports[`t-slot directive slots are rendered with proper context, part 2 2`] = `
}
extra.promises.push(def8);
}
- return vn1;
+ return result;
}"
`;
@@ -1580,15 +1648,17 @@ exports[`t-slot directive slots are rendered with proper context, part 3 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
var _1 = context['props'].to;
let c2 = [], p2 = {key:2,attrs:{href: _1}};
var vn2 = h('a', p2, c2);
+ result = vn2;
const slot3 = this.slots[context.__owl__.slotId + '_' + 'default'];
if (slot3) {
slot3.call(this, context.__owl__.parent, Object.assign({}, extra, {parentNode: c2, vars: extra.vars, parent: owner}));
}
- return vn2;
+ return result;
}"
`;
@@ -1599,11 +1669,13 @@ exports[`t-slot directive slots are rendered with proper context, part 3 2`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
context = Object.create(context);
const scope = Object.create(null);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('u', p2, c2);
c1.push(vn2);
@@ -1661,7 +1733,7 @@ exports[`t-slot directive slots are rendered with proper context, part 3 2`] = `
}
extra.promises.push(def9);
}
- return vn1;
+ return result;
}"
`;
@@ -1685,9 +1757,11 @@ exports[`t-slot directive slots are rendered with proper context, part 4 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 'User '+context['state'].user.name;
//COMPONENT
let def4;
@@ -1717,7 +1791,7 @@ exports[`t-slot directive slots are rendered with proper context, part 4 1`] = `
def4 = def4.then(()=>{if (w5.__owl__.isDestroyed) {return};let pvnode=w5.__owl__.pvnode;c1[_3_index]=pvnode;});
}
extra.promises.push(def4);
- return vn1;
+ return result;
}"
`;
diff --git a/tests/component/__snapshots__/props_validation.test.ts.snap b/tests/component/__snapshots__/props_validation.test.ts.snap
index 9d2dadd4..131a8288 100644
--- a/tests/component/__snapshots__/props_validation.test.ts.snap
+++ b/tests/component/__snapshots__/props_validation.test.ts.snap
@@ -11,9 +11,11 @@ exports[`props validation props are validated in dev mode (code snapshot) 1`] =
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
//COMPONENT
let def3;
let w4 = 4 in parent.__owl__.cmap ? parent.__owl__.children[parent.__owl__.cmap[4]] : false;
@@ -43,6 +45,6 @@ exports[`props validation props are validated in dev mode (code snapshot) 1`] =
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
- return vn1;
+ return result;
}"
`;
diff --git a/tests/component/component.test.ts b/tests/component/component.test.ts
index 566df134..67e9db18 100644
--- a/tests/component/component.test.ts
+++ b/tests/component/component.test.ts
@@ -4271,3 +4271,91 @@ describe("unmounting and remounting", () => {
expect(fixture.innerHTML).toBe("
3
");
});
});
+
+describe("dynamic root nodes", () => {
+ test("template with t-if, part 1", async () => {
+ env.qweb.addTemplates(`
+
+
+ hey
+ abc
+
+
+ `);
+ class TestWidget extends Widget {}
+
+ const widget = new TestWidget(env);
+ await widget.mount(fixture);
+
+ expect(fixture.innerHTML).toBe("hey");
+ });
+
+ test("template with t-if, part 2", async () => {
+ env.qweb.addTemplates(`
+
+
+ hey
+ abc
+
+
+ `);
+ class TestWidget extends Widget {}
+
+ const widget = new TestWidget(env);
+ await widget.mount(fixture);
+
+ expect(fixture.innerHTML).toBe("abc
");
+ });
+
+ test("switching between sub branches dynamically", async () => {
+ env.qweb.addTemplates(`
+
+
+ hey
+ abc
+
+
+ `);
+ class TestWidget extends Widget {
+ state = {flag: true};
+ }
+
+ const widget = new TestWidget(env);
+ await widget.mount(fixture);
+
+ expect(fixture.innerHTML).toBe("hey");
+ widget.state.flag = false;
+ await nextTick();
+
+ expect(fixture.innerHTML).toBe("abc
");
+ });
+
+ test("switching between sub components dynamically", async () => {
+ env.qweb.addTemplates(`
+
+ hey
+ abc
+
+
+
+
+
+ `);
+ class ChildA extends Widget {}
+ class ChildB extends Widget {}
+ class TestWidget extends Widget {
+ static components = {ChildA, ChildB};
+ state = {flag: true};
+ }
+
+ const widget = new TestWidget(env);
+ await widget.mount(fixture);
+
+ expect(fixture.innerHTML).toBe("hey");
+ widget.state.flag = false;
+ await nextTick();
+
+ expect(fixture.innerHTML).toBe("abc
");
+ });
+
+});
\ No newline at end of file
diff --git a/tests/qweb/__snapshots__/qweb.test.ts.snap b/tests/qweb/__snapshots__/qweb.test.ts.snap
index 3ca6146f..616d4f59 100644
--- a/tests/qweb/__snapshots__/qweb.test.ts.snap
+++ b/tests/qweb/__snapshots__/qweb.test.ts.snap
@@ -3,121 +3,143 @@
exports[`attributes class and t-attf-class with ternary operation 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = 'hello ' + (context['value']?'world':'');
let c2 = [], p2 = {key:2,attrs:{class: _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes dynamic attribute falsy variable 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = context['value'];
let c2 = [], p2 = {key:2,attrs:{foo: _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes dynamic attribute with a dash 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = context['id'];
let c2 = [], p2 = {key:2,attrs:{\\"data-action-id\\": _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes dynamic attributes 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = 'bar';
let c2 = [], p2 = {key:2,attrs:{foo: _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes dynamic formatted attributes with a dash 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = \`Some text \${context['id']}\`;
let c2 = [], p2 = {key:2,attrs:{\\"aria-label\\": _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes fixed variable 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = context['value'];
let c2 = [], p2 = {key:2,attrs:{foo: _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes format expression 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = (context['value']+37);
let c2 = [], p2 = {key:2,attrs:{foo: _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes format expression, other format 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = (context['value']+37);
let c2 = [], p2 = {key:2,attrs:{foo: _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes format literal 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = \`bar\`;
let c2 = [], p2 = {key:2,attrs:{foo: _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes format multiple 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = \`a \${context['value1']} is \${context['value2']} of \${context['value3']} ]\`;
let c2 = [], p2 = {key:2,attrs:{foo: _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes format value 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = \`b\${context['value']}r\`;
let c2 = [], p2 = {key:2,attrs:{foo: _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
@@ -125,15 +147,17 @@ exports[`attributes from object variables set previously 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = {a:'b'};
let _3 = utils.toObj(_2.a);
let c4 = [], p4 = {key:4,class:_3};
var vn4 = h('span', p4, c4);
c1.push(vn4);
- return vn1;
+ return result;
}"
`;
@@ -141,21 +165,24 @@ exports[`attributes from variables set previously 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 'def';
let _3 = utils.toObj(_2);
let c4 = [], p4 = {key:4,class:_3};
var vn4 = h('span', p4, c4);
c1.push(vn4);
- return vn1;
+ return result;
}"
`;
exports[`attributes object 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = context['value'];
let c2 = [], p2 = {key:2,attrs:{}};
@@ -167,43 +194,50 @@ exports[`attributes object 1`] = `
}
}
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes static attributes 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = 'a';
var _2 = 'b';
var _3 = 'c';
let c4 = [], p4 = {key:4,attrs:{foo: _1,bar: _2,baz: _3}};
var vn4 = h('div', p4, c4);
- return vn4;
+ result = vn4;
+ return result;
}"
`;
exports[`attributes static attributes on void elements 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = '/test.jpg';
var _2 = 'Test';
let c3 = [], p3 = {key:3,attrs:{src: _1,alt: _2}};
var vn3 = h('img', p3, c3);
- return vn3;
+ result = vn3;
+ return result;
}"
`;
exports[`attributes static attributes with dashes 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = 'Close';
let c2 = [], p2 = {key:2,attrs:{\\"aria-label\\": _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
@@ -211,12 +245,14 @@ exports[`attributes t-att-class and class should combine together 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let _2 = {'hello':true};
Object.assign(_2, utils.toObj(context['value']))
let c3 = [], p3 = {key:3,class:_2};
var vn3 = h('div', p3, c3);
- return vn3;
+ result = vn3;
+ return result;
}"
`;
@@ -224,29 +260,34 @@ exports[`attributes t-att-class with object 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let _2 = {'static':true};
Object.assign(_2, utils.toObj({a:context['b'],c:context['d'],e:context['f']}))
let c3 = [], p3 = {key:3,class:_2};
var vn3 = h('div', p3, c3);
- return vn3;
+ result = vn3;
+ return result;
}"
`;
exports[`attributes t-attf-class should combine with class 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = 'hello ' + \`world\`;
let c2 = [], p2 = {key:2,attrs:{class: _1}};
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes tuple literal 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = ['foo','bar'];
let c2 = [], p2 = {key:2,attrs:{}};
@@ -258,13 +299,15 @@ exports[`attributes tuple literal 1`] = `
}
}
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`attributes tuple variable 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = context['value'];
let c2 = [], p2 = {key:2,attrs:{}};
@@ -276,17 +319,20 @@ exports[`attributes tuple variable 1`] = `
}
}
var vn2 = h('div', p2, c2);
- return vn2;
+ result = vn2;
+ return result;
}"
`;
exports[`debugging t-debug 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
debugger;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (true) {
debugger;
let c2 = [], p2 = {key:2};
@@ -294,29 +340,33 @@ exports[`debugging t-debug 1`] = `
c1.push(vn2);
c2.push({text: \`hey\`});
}
- return vn1;
+ return result;
}"
`;
exports[`debugging t-log 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 42;
console.log(_2+3)
- return vn1;
+ return result;
}"
`;
exports[`foreach does not pollute the rendering context 1`] = `
"function anonymous(context,extra
) {
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = [1];
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -336,17 +386,19 @@ exports[`foreach does not pollute the rendering context 1`] = `
c1.push({text: _5});
}
}
- return vn1;
+ return result;
}"
`;
exports[`foreach iterate on items (on a element node) 1`] = `
"function anonymous(context,extra
) {
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = [1,2];
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -370,17 +422,19 @@ exports[`foreach iterate on items (on a element node) 1`] = `
c5.push({text: _6});
}
}
- return vn1;
+ return result;
}"
`;
exports[`foreach iterate on items 1`] = `
"function anonymous(context,extra
) {
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = [3,2,1];
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -412,17 +466,19 @@ exports[`foreach iterate on items 1`] = `
}
c1.push({text: \`] \`});
}
- return vn1;
+ return result;
}"
`;
exports[`foreach iterate, dict param 1`] = `
"function anonymous(context,extra
) {
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['value'];
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -454,17 +510,19 @@ exports[`foreach iterate, dict param 1`] = `
}
c1.push({text: \`] \`});
}
- return vn1;
+ return result;
}"
`;
exports[`foreach iterate, position 1`] = `
"function anonymous(context,extra
) {
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = Array(5);
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -493,17 +551,19 @@ exports[`foreach iterate, position 1`] = `
}
c1.push({text: \`) \`});
}
- return vn1;
+ return result;
}"
`;
exports[`foreach warn if no key in some case 1`] = `
"function anonymous(context,extra
) {
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = [1,2];
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -526,27 +586,31 @@ exports[`foreach warn if no key in some case 1`] = `
c5.push({text: _6});
}
}
- return vn1;
+ return result;
}"
`;
exports[`loading templates can initialize qweb with a string 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
c1.push({text: \`jupiler\`});
- return vn1;
+ return result;
}"
`;
exports[`loading templates can load a few templates from a xml string 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('ul', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('li', p2, c2);
c1.push(vn2);
@@ -555,7 +619,7 @@ exports[`loading templates can load a few templates from a xml string 1`] = `
var vn3 = h('li', p3, c3);
c1.push(vn3);
c3.push({text: \`foo\`});
- return vn1;
+ return result;
}"
`;
@@ -563,10 +627,12 @@ exports[`misc global 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = [4,5,6];
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -639,28 +705,32 @@ exports[`misc global 1`] = `
} else {
c21.push({text: \`toto default\`});
}
- return vn1;
+ return result;
}"
`;
exports[`special cases for some boolean html attributes/properties input type= checkbox, with t-att-checked 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = 'checkbox';
var _2 = context['flag'];
let c3 = [], p3 = {key:3,attrs:{type: _1,checked: _2},props:{checked: _2}};
var vn3 = h('input', p3, c3);
- return vn3;
+ result = vn3;
+ return result;
}"
`;
exports[`special cases for some boolean html attributes/properties various boolean html attributes 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 'checkbox';
var _3 = 'checked';
let c4 = [], p4 = {key:4,attrs:{type: _2,checked: _3},props:{checked: _3}};
@@ -691,96 +761,112 @@ exports[`special cases for some boolean html attributes/properties various boole
let c17 = [], p17 = {key:17,attrs:{disabled: _16},props:{disabled: _16}};
var vn17 = h('button', p17, c17);
c1.push(vn17);
- return vn1;
+ return result;
}"
`;
exports[`static templates div with a span child node 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('span', p2, c2);
c1.push(vn2);
c2.push({text: \`word\`});
- return vn1;
+ return result;
}"
`;
exports[`static templates div with a text node 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
c1.push({text: \`word\`});
- return vn1;
+ return result;
}"
`;
exports[`static templates empty div 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
- return vn1;
+ result = vn1;
+ return result;
}"
`;
exports[`static templates simple dynamic value 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var _1 = context['text'];
if (_1 || _1 === 0) {
var vn2 = {text: _1};
+ result = vn2
}
- return vn2;
+ return result;
}"
`;
exports[`static templates simple string 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var vn1 = {text: \`hello vdom\`};
- return vn1;
+ result = vn1;
+ return result;
}"
`;
exports[`static templates simple string, with some dynamic value 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var vn1 = {text: \`hello \`};
+ result = vn1;
var _2 = context['text'];
if (_2 || _2 === 0) {
vn1.text += _2;
}
- return vn1;
+ return result;
}"
`;
exports[`t-call (template calling basic caller 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
c1.push({text: \`ok\`});
- return vn1;
+ return result;
}"
`;
exports[`t-call (template calling call with several sub nodes on same line 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c5 = [], p5 = {key:5};
var vn5 = h('div', p5, c5);
c1.push(vn5);
@@ -793,21 +879,23 @@ exports[`t-call (template calling call with several sub nodes on same line 1`] =
var vn7 = h('span', p7, c7);
c5.push(vn7);
c7.push({text: \`yay\`});
- return vn1;
+ return result;
}"
`;
exports[`t-call (template calling inherit context 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 1;
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
@@ -815,9 +903,11 @@ exports[`t-call (template calling recursive template, part 1 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('span', p2, c2);
c1.push(vn2);
@@ -825,7 +915,7 @@ exports[`t-call (template calling recursive template, part 1 1`] = `
if (false) {
this.recursiveFns['__3'].call(this, context, Object.assign({}, extra, {parentNode: c1, vars: {}, scope}));
}
- return vn1;
+ return result;
}"
`;
@@ -853,11 +943,13 @@ exports[`t-call (template calling recursive template, part 2 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
context = Object.create(context);
const scope = Object.create(null);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
{
let _2 = context['root'];
let c3 = [], p3 = {key:3};
@@ -892,7 +984,7 @@ exports[`t-call (template calling recursive template, part 2 1`] = `
this.recursiveFns['__10'].call(this, context, Object.assign({}, extra, {parentNode: c3, vars: {_v0: context['subtree']}, scope}));
}
}
- return vn1;
+ return result;
}"
`;
@@ -944,11 +1036,13 @@ exports[`t-call (template calling recursive template, part 3 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
context = Object.create(context);
const scope = Object.create(null);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
{
let _2 = context['root'];
let c3 = [], p3 = {key:3};
@@ -983,7 +1077,7 @@ exports[`t-call (template calling recursive template, part 3 1`] = `
this.recursiveFns['__10'].call(this, context, Object.assign({}, extra, {parentNode: c3, vars: {_v0: context['subtree']}, scope}));
}
}
- return vn1;
+ return result;
}"
`;
@@ -1034,9 +1128,11 @@ exports[`t-call (template calling recursive template, part 3 2`] = `
exports[`t-call (template calling scoped parameters 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
{
let _2 = 42;
c1.push({text: \`ok\`});
@@ -1045,158 +1141,180 @@ exports[`t-call (template calling scoped parameters 1`] = `
if (_3 || _3 === 0) {
c1.push({text: _3});
}
- return vn1;
+ return result;
}"
`;
exports[`t-call (template calling t-call with t-if 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['flag']) {
let c2 = [], p2 = {key:2};
var vn2 = h('span', p2, c2);
c1.push(vn2);
c2.push({text: \`ok\`});
}
- return vn1;
+ return result;
}"
`;
exports[`t-call (template calling with unused body 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c2 = [], p2 = {key:2};
var vn2 = h('div', p2, c2);
+ result = vn2;
c2.push({text: \`ok\`});
- return vn2;
+ return result;
}"
`;
exports[`t-call (template calling with unused setbody 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
{
let _1 = 3;
let c2 = [], p2 = {key:2};
var vn2 = h('div', p2, c2);
+ result = vn2;
c2.push({text: \`ok\`});
}
- return vn2;
+ return result;
}"
`;
exports[`t-call (template calling with used body 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c2 = [], p2 = {key:2};
var vn2 = h('h1', p2, c2);
+ result = vn2;
c2.push({text: \`ok\`});
- return vn2;
+ return result;
}"
`;
exports[`t-call (template calling with used set body 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('span', p1, c1);
+ result = vn1;
{
let _2 = 'ok';
if (_2 || _2 === 0) {
c1.push({text: _2});
}
}
- return vn1;
+ return result;
}"
`;
exports[`t-esc escaping on a node 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1,on:{}};
var vn1 = h('span', p1, c1);
+ result = vn1;
var _2 = 'ok';
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`t-esc escaping on a node with a body 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1,on:{}};
var vn1 = h('span', p1, c1);
+ result = vn1;
var _2 = 'ok';
if (_2 || _2 === 0) {
c1.push({text: _2});
} else {
c1.push({text: \`nope\`});
}
- return vn1;
+ return result;
}"
`;
exports[`t-esc escaping on a node with a body, as a default 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1,on:{}};
var vn1 = h('span', p1, c1);
+ result = vn1;
var _2 = context['var'];
if (_2 || _2 === 0) {
c1.push({text: _2});
} else {
c1.push({text: \`nope\`});
}
- return vn1;
+ return result;
}"
`;
exports[`t-esc literal 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('span', p1, c1);
+ result = vn1;
var _2 = 'ok';
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`t-esc variable 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('span', p1, c1);
+ result = vn1;
var _2 = context['var'];
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`t-if boolean value condition elif 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['color']=='black') {
c1.push({text: \`black pearl\`});
}
@@ -1209,16 +1327,18 @@ exports[`t-if boolean value condition elif 1`] = `
else {
c1.push({text: \`beer\`});
}
- return vn1;
+ return result;
}"
`;
exports[`t-if boolean value condition else 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('span', p2, c2);
c1.push(vn2);
@@ -1233,16 +1353,18 @@ exports[`t-if boolean value condition else 1`] = `
var vn3 = h('span', p3, c3);
c1.push(vn3);
c3.push({text: \`end\`});
- return vn1;
+ return result;
}"
`;
exports[`t-if boolean value condition false else 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('span', p2, c2);
c1.push(vn2);
@@ -1257,55 +1379,63 @@ exports[`t-if boolean value condition false else 1`] = `
var vn3 = h('span', p3, c3);
c1.push(vn3);
c3.push({text: \`end\`});
- return vn1;
+ return result;
}"
`;
exports[`t-if boolean value condition missing 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('span', p1, c1);
+ result = vn1;
if (context['condition']) {
c1.push({text: \`fail\`});
}
- return vn1;
+ return result;
}"
`;
exports[`t-if boolean value false condition 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['condition']) {
c1.push({text: \`ok\`});
}
- return vn1;
+ return result;
}"
`;
exports[`t-if boolean value true condition 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['condition']) {
c1.push({text: \`ok\`});
}
- return vn1;
+ return result;
}"
`;
exports[`t-if can use some boolean operators in expressions 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['cond1']&&context['cond2']) {
c1.push({text: \`and\`});
}
@@ -1330,32 +1460,36 @@ exports[`t-if can use some boolean operators in expressions 1`] = `
if (context['n']<3) {
c1.push({text: \`nlt\`});
}
- return vn1;
+ return result;
}"
`;
exports[`t-key can use t-key directive on a node 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
const nodeKey1 = context['beer'].id
let c1 = [], p1 = {key:nodeKey1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['beer'].name;
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`t-key t-key directive in a list 1`] = `
"function anonymous(context,extra
) {
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('ul', p1, c1);
+ result = vn1;
var _2 = context['beers'];
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -1379,7 +1513,7 @@ exports[`t-key t-key directive in a list 1`] = `
c5.push({text: _6});
}
}
- return vn1;
+ return result;
}"
`;
@@ -1389,16 +1523,18 @@ exports[`t-on can bind event handler 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1,on:{}};
var vn1 = h('button', p1, c1);
+ result = vn1;
if (!context['add']) {
throw new Error('Missing handler \\\\'' + 'add' + \`\\\\' when evaluating template 'test'\`)
}
extra.handlers['click' + 1] = extra.handlers['click' + 1] || context['add'].bind(owner);
p1.on['click'] = extra.handlers['click' + 1];
c1.push({text: \`Click\`});
- return vn1;
+ return result;
}"
`;
@@ -1406,15 +1542,17 @@ exports[`t-on can bind handlers with arguments 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1,on:{}};
var vn1 = h('button', p1, c1);
+ result = vn1;
if (!context['add']) {
throw new Error('Missing handler \\\\'' + 'add' + \`\\\\' when evaluating template 'test'\`)
}
p1.on['click'] = context['add'].bind(owner, 5);
c1.push({text: \`Click\`});
- return vn1;
+ return result;
}"
`;
@@ -1422,15 +1560,17 @@ exports[`t-on can bind handlers with empty object (with non empty inner string)
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1,on:{}};
var vn1 = h('button', p1, c1);
+ result = vn1;
if (!context['doSomething']) {
throw new Error('Missing handler \\\\'' + 'doSomething' + \`\\\\' when evaluating template 'test'\`)
}
p1.on['click'] = context['doSomething'].bind(owner, {});
c1.push({text: \`Click\`});
- return vn1;
+ return result;
}"
`;
@@ -1438,15 +1578,17 @@ exports[`t-on can bind handlers with empty object 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1,on:{}};
var vn1 = h('button', p1, c1);
+ result = vn1;
if (!context['doSomething']) {
throw new Error('Missing handler \\\\'' + 'doSomething' + \`\\\\' when evaluating template 'test'\`)
}
p1.on['click'] = context['doSomething'].bind(owner, {});
c1.push({text: \`Click\`});
- return vn1;
+ return result;
}"
`;
@@ -1454,10 +1596,12 @@ exports[`t-on can bind handlers with loop variable as argument 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('ul', p1, c1);
+ result = vn1;
var _2 = ['someval'];
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -1485,7 +1629,7 @@ exports[`t-on can bind handlers with loop variable as argument 1`] = `
p6.on['click'] = context['activate'].bind(owner, context['action']);
c6.push({text: \`link\`});
}
- return vn1;
+ return result;
}"
`;
@@ -1493,15 +1637,17 @@ exports[`t-on can bind handlers with object arguments 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1,on:{}};
var vn1 = h('button', p1, c1);
+ result = vn1;
if (!context['add']) {
throw new Error('Missing handler \\\\'' + 'add' + \`\\\\' when evaluating template 'test'\`)
}
p1.on['click'] = context['add'].bind(owner, {val:5});
c1.push({text: \`Click\`});
- return vn1;
+ return result;
}"
`;
@@ -1509,9 +1655,11 @@ exports[`t-on can bind two event handlers 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1,on:{}};
var vn1 = h('button', p1, c1);
+ result = vn1;
if (!context['handleClick']) {
throw new Error('Missing handler \\\\'' + 'handleClick' + \`\\\\' when evaluating template 'test'\`)
}
@@ -1523,7 +1671,7 @@ exports[`t-on can bind two event handlers 1`] = `
extra.handlers['dblclick' + 1] = extra.handlers['dblclick' + 1] || context['handleDblClick'].bind(owner);
p1.on['dblclick'] = extra.handlers['dblclick' + 1];
c1.push({text: \`Click\`});
- return vn1;
+ return result;
}"
`;
@@ -1531,16 +1679,18 @@ exports[`t-on handler is bound to proper owner 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1,on:{}};
var vn1 = h('button', p1, c1);
+ result = vn1;
if (!context['add']) {
throw new Error('Missing handler \\\\'' + 'add' + \`\\\\' when evaluating template 'test'\`)
}
extra.handlers['click' + 1] = extra.handlers['click' + 1] || context['add'].bind(owner);
p1.on['click'] = extra.handlers['click' + 1];
c1.push({text: \`Click\`});
- return vn1;
+ return result;
}"
`;
@@ -1548,9 +1698,11 @@ exports[`t-on t-on with prevent and self modifiers (order matters) 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('button', p2, c2);
c1.push(vn2);
@@ -1563,7 +1715,7 @@ exports[`t-on t-on with prevent and self modifiers (order matters) 1`] = `
var vn3 = h('span', p3, c3);
c2.push(vn3);
c3.push({text: \`Button\`});
- return vn1;
+ return result;
}"
`;
@@ -1571,9 +1723,11 @@ exports[`t-on t-on with prevent and/or stop modifiers 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('button', p2, c2);
c1.push(vn2);
@@ -1601,7 +1755,7 @@ exports[`t-on t-on with prevent and/or stop modifiers 1`] = `
extra.handlers['click' + 4] = extra.handlers['click' + 4] || function (e) {e.preventDefault();e.stopPropagation();context['onClickPreventedAndStopped'].call(owner, e);};
p4.on['click'] = extra.handlers['click' + 4];
c4.push({text: \`Button 3\`});
- return vn1;
+ return result;
}"
`;
@@ -1609,9 +1763,11 @@ exports[`t-on t-on with self and prevent modifiers (order matters) 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('button', p2, c2);
c1.push(vn2);
@@ -1624,7 +1780,7 @@ exports[`t-on t-on with self and prevent modifiers (order matters) 1`] = `
var vn3 = h('span', p3, c3);
c2.push(vn3);
c3.push({text: \`Button\`});
- return vn1;
+ return result;
}"
`;
@@ -1632,9 +1788,11 @@ exports[`t-on t-on with self modifier 1`] = `
"function anonymous(context,extra
) {
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2,on:{}};
var vn2 = h('button', p2, c2);
c1.push(vn2);
@@ -1659,7 +1817,7 @@ exports[`t-on t-on with self modifier 1`] = `
var vn5 = h('span', p5, c5);
c4.push(vn5);
c5.push({text: \`Button\`});
- return vn1;
+ return result;
}"
`;
@@ -1667,9 +1825,11 @@ exports[`t-raw literal 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('span', p1, c1);
+ result = vn1;
var _2 = 'ok';
if (_2 || _2 === 0) {
var frag3 = utils.getFragment(_2)
@@ -1679,7 +1839,7 @@ exports[`t-raw literal 1`] = `
var vn4 = h('div', p4)
c1.push(vn4);
}
- return vn1;
+ return result;
}"
`;
@@ -1687,9 +1847,11 @@ exports[`t-raw not escaping 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['var'];
if (_2 || _2 === 0) {
var frag3 = utils.getFragment(_2)
@@ -1699,7 +1861,7 @@ exports[`t-raw not escaping 1`] = `
var vn4 = h('div', p4)
c1.push(vn4);
}
- return vn1;
+ return result;
}"
`;
@@ -1707,9 +1869,11 @@ exports[`t-raw t-raw and another sibling node 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('span', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('span', p2, c2);
c1.push(vn2);
@@ -1723,7 +1887,7 @@ exports[`t-raw t-raw and another sibling node 1`] = `
var vn5 = h('div', p5)
c1.push(vn5);
}
- return vn1;
+ return result;
}"
`;
@@ -1731,9 +1895,11 @@ exports[`t-raw variable 1`] = `
"function anonymous(context,extra
) {
let utils = this.constructor.utils;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('span', p1, c1);
+ result = vn1;
var _2 = context['var'];
if (_2 || _2 === 0) {
var frag3 = utils.getFragment(_2)
@@ -1743,16 +1909,18 @@ exports[`t-raw variable 1`] = `
var vn4 = h('div', p4)
c1.push(vn4);
}
- return vn1;
+ return result;
}"
`;
exports[`t-ref can get a dynamic ref on a node 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('span', p2, c2);
c1.push(vn2);
@@ -1762,16 +1930,18 @@ exports[`t-ref can get a dynamic ref on a node 1`] = `
context.refs[ref3] = n.elm;
},
};
- return vn1;
+ return result;
}"
`;
exports[`t-ref can get a ref on a node 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('span', p2, c2);
c1.push(vn2);
@@ -1781,17 +1951,19 @@ exports[`t-ref can get a ref on a node 1`] = `
context.refs[ref3] = n.elm;
},
};
- return vn1;
+ return result;
}"
`;
exports[`t-ref refs in a loop 1`] = `
"function anonymous(context,extra
) {
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['items'];
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
var _3 = _4 = _2;
@@ -1821,119 +1993,137 @@ exports[`t-ref refs in a loop 1`] = `
c5.push({text: _7});
}
}
- return vn1;
+ return result;
}"
`;
exports[`t-set evaluate value expression 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 1+2;
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`t-set evaluate value expression, part 2 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['somevariable']+2;
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`t-set set from attribute literal 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 'ok';
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`t-set set from attribute lookup 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['value'];
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`t-set set from body literal 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
var vn1 = {text: \`ok\`};
- return vn1;
+ result = vn1;
+ return result;
}"
`;
exports[`t-set set from body lookup 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['value'];
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`t-set set from empty body 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
- return vn1;
+ result = vn1;
+ return result;
}"
`;
exports[`t-set t-set and t-if 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['value'];
if (_2==='ok') {
c1.push({text: \`grimbergen\`});
}
- return vn1;
+ return result;
}"
`;
exports[`t-set t-set evaluates an expression only once 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = context['value']+' artois';
if (_2 || _2 === 0) {
c1.push({text: _2});
@@ -1941,17 +2131,19 @@ exports[`t-set t-set evaluates an expression only once 1`] = `
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`t-set t-set should reuse variable if possible 1`] = `
"function anonymous(context,extra
) {
+ let result;
context = Object.create(context);
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 1;
var _3 = context['list'];
if (!_3) { throw new Error('QWeb error: Invalid loop expression')}
@@ -1980,93 +2172,107 @@ exports[`t-set t-set should reuse variable if possible 1`] = `
}
_2 = context['elem']
}
- return vn1;
+ return result;
}"
`;
exports[`t-set value priority 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
var _2 = 1;
if (_2 || _2 === 0) {
c1.push({text: _2});
}
- return vn1;
+ return result;
}"
`;
exports[`whitespace handling consecutives whitespaces are condensed into a single space 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
c1.push({text: \` abc \`});
- return vn1;
+ return result;
}"
`;
exports[`whitespace handling nothing is done in pre tags 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('pre', p1, c1);
+ result = vn1;
c1.push({text: \` \`});
- return vn1;
+ return result;
}"
`;
exports[`whitespace handling nothing is done in pre tags 2`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('pre', p1, c1);
+ result = vn1;
c1.push({text: \`
some text
\`});
- return vn1;
+ return result;
}"
`;
exports[`whitespace handling nothing is done in pre tags 3`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('pre', p1, c1);
+ result = vn1;
c1.push({text: \`
\`});
- return vn1;
+ return result;
}"
`;
exports[`whitespace handling white space only text nodes are condensed into a single space 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
c1.push({text: \` \`});
- return vn1;
+ return result;
}"
`;
exports[`whitespace handling whitespace only text nodes with newlines are removed 1`] = `
"function anonymous(context,extra
) {
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
let c2 = [], p2 = {key:2};
var vn2 = h('span', p2, c2);
c1.push(vn2);
c2.push({text: \`abc\`});
- return vn1;
+ return result;
}"
`;
diff --git a/tests/router/__snapshots__/Link.test.ts.snap b/tests/router/__snapshots__/Link.test.ts.snap
index daf9e966..e03ebed3 100644
--- a/tests/router/__snapshots__/Link.test.ts.snap
+++ b/tests/router/__snapshots__/Link.test.ts.snap
@@ -5,11 +5,13 @@ exports[`Link component can render simple cases 1`] = `
) {
let utils = this.constructor.utils;
let owner = context;
+ let result;
var h = this.h;
let _1 = utils.toObj({'router-link-active':context['isActive']});
var _2 = context['href'];
let c3 = [], p3 = {key:3,attrs:{href: _2},class:_1,on:{}};
var vn3 = h('a', p3, c3);
+ result = vn3;
if (!context['navigate']) {
throw new Error('Missing handler \\\\'' + 'navigate' + \`\\\\' when evaluating template '__owl__-router-link'\`)
}
@@ -19,6 +21,6 @@ exports[`Link component can render simple cases 1`] = `
if (slot4) {
slot4.call(this, context.__owl__.parent, Object.assign({}, extra, {parentNode: c3, vars: extra.vars, parent: owner}));
}
- return vn3;
+ return result;
}"
`;
diff --git a/tests/router/__snapshots__/directive.test.ts.snap b/tests/router/__snapshots__/directive.test.ts.snap
index f6697786..be3ce663 100644
--- a/tests/router/__snapshots__/directive.test.ts.snap
+++ b/tests/router/__snapshots__/directive.test.ts.snap
@@ -7,9 +7,11 @@ exports[`router directive t-routecomponent can render parameterized route 1`] =
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['env'].router.currentRouteName==='book') {
//COMPONENT
let def3;
@@ -39,7 +41,7 @@ exports[`router directive t-routecomponent can render parameterized route 1`] =
}
extra.promises.push(def3);
}
- return vn1;
+ return result;
}"
`;
@@ -50,9 +52,11 @@ exports[`router directive t-routecomponent can render parameterized route with s
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['env'].router.currentRouteName==='book') {
//COMPONENT
let def3;
@@ -82,7 +86,7 @@ exports[`router directive t-routecomponent can render parameterized route with s
}
extra.promises.push(def3);
}
- return vn1;
+ return result;
}"
`;
@@ -93,9 +97,11 @@ exports[`router directive t-routecomponent can render simple cases 1`] = `
let QWeb = this.constructor;
let parent = context;
let owner = context;
+ let result;
var h = this.h;
let c1 = [], p1 = {key:1};
var vn1 = h('div', p1, c1);
+ result = vn1;
if (context['env'].router.currentRouteName==='about') {
//COMPONENT
let def3;
@@ -154,6 +160,6 @@ exports[`router directive t-routecomponent can render simple cases 1`] = `
}
extra.promises.push(def6);
}
- return vn1;
+ return result;
}"
`;