[REF] qweb: mostly revert fix with t-call and vars with body

The previous fix (overriding tostring of VDomArray) is actually more
general, and solves the same issue. So, let us simplify the code and
keep the more general solution.

This reverts commit 3bf91afc3f.
This commit is contained in:
Géry Debongnie
2020-09-16 15:28:23 +02:00
committed by aab-odoo
parent 06d852fcf9
commit 7b8ac13d3f
5 changed files with 2 additions and 15 deletions
+1 -7
View File
@@ -41,12 +41,6 @@ function compileValueNode(value: any, node: Element, qweb: QWeb, ctx: Compilatio
if (typeof value === "string") {
exprID = `_${ctx.generateID()}`;
ctx.addLine(`let ${exprID} = ${ctx.formatExpression(value)};`);
if (ctx.isSubTemplate) {
ctx.rootContext.shouldDefineUtils = true;
ctx.addLine(
`${exprID} = ${exprID} instanceof utils.VDomArray ? utils.vDomToString(${exprID}) : ${exprID};`
);
}
} else {
exprID = `scope.${value.id}`;
}
@@ -244,7 +238,7 @@ QWeb.addDirective({
if (!subId) {
subId = QWeb.nextId++;
qweb.subTemplates[subTemplate] = subId;
const subTemplateFn = qweb._compile(subTemplate, nodeTemplate.elem, ctx, true, true);
const subTemplateFn = qweb._compile(subTemplate, nodeTemplate.elem, ctx, true);
QWeb.subTemplates[subId] = subTemplateFn;
}
-1
View File
@@ -22,7 +22,6 @@ export class CompilationContext {
shouldDefineUtils: boolean = false;
shouldDefineRefs: boolean = false;
shouldDefineResult: boolean = true;
isSubTemplate: boolean = false;
loopNumber: number = 0;
inPreTag: boolean = false;
templateName: string;
+1 -3
View File
@@ -421,12 +421,10 @@ export class QWeb extends EventBus {
name: string,
elem: Element,
parentContext?: CompilationContext,
defineKey?: boolean,
isSubTemplate?: boolean
defineKey?: boolean
): CompiledTemplate {
const isDebug = elem.attributes.hasOwnProperty("t-debug");
const ctx = new CompilationContext(name);
ctx.isSubTemplate = Boolean(isSubTemplate);
if (elem.tagName !== "t") {
ctx.shouldDefineResult = false;
}
-1
View File
@@ -1766,7 +1766,6 @@ describe("props evaluation ", () => {
await widget.mount(fixture);
expect(fixture.innerHTML).toBe("<div><span>&lt;p&gt;4343&lt;/p&gt;<p>43</p></span></div>");
});
});
describe("other directives with t-component", () => {
@@ -1502,7 +1502,6 @@ exports[`t-call (template calling recursive template, part 2 2`] = `
let vn3 = h('p', p3, c3);
c2.push(vn3);
let _4 = scope['node'].val;
_4 = _4 instanceof utils.VDomArray ? utils.vDomToString(_4) : _4;
if (_4 != null) {
c3.push({text: _4});
}
@@ -1582,7 +1581,6 @@ exports[`t-call (template calling recursive template, part 3 2`] = `
let vn3 = h('p', p3, c3);
c2.push(vn3);
let _4 = scope['node'].val;
_4 = _4 instanceof utils.VDomArray ? utils.vDomToString(_4) : _4;
if (_4 != null) {
c3.push({text: _4});
}
@@ -1664,7 +1662,6 @@ exports[`t-call (template calling recursive template, part 4: with t-set recursi
let vn3 = h('p', p3, c3);
c2.push(vn3);
let _4 = scope['node'].val;
_4 = _4 instanceof utils.VDomArray ? utils.vDomToString(_4) : _4;
if (_4 != null) {
c3.push({text: _4});
}