From 2fbb75912470ee2f32a32e34d946d0183ec053c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 29 Jun 2022 09:17:27 +0000 Subject: [PATCH] [IMP] web: update owl from 2.0.0-beta-11 to 2.0.0-beta-12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Release notes: https://github.com/odoo/owl/releases/tag/v2.0.0-beta-12 Details [FIX] compiler: properly handle t-set in t-if with no content closes odoo/odoo#94868 X-original-commit: 942a7affd03e716d4b3271d2a3d62979ee90f625 Signed-off-by: Samuel Degueldre Signed-off-by: Géry Debongnie --- addons/web/static/lib/owl/owl.js | 41 +++++++++++++++----------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/addons/web/static/lib/owl/owl.js b/addons/web/static/lib/owl/owl.js index ab6b70902b9..c82af9d3b52 100644 --- a/addons/web/static/lib/owl/owl.js +++ b/addons/web/static/lib/owl/owl.js @@ -3677,8 +3677,8 @@ define(varName, expr) { this.addLine(`const ${varName} = ${expr};`); } - insertAnchor(block) { - const tag = `block-child-${block.children.length}`; + insertAnchor(block, index = block.children.length) { + const tag = `block-child-${index}`; const anchor = xmlDoc.createElement(tag); block.insert(anchor); } @@ -4089,9 +4089,18 @@ } this.insertBlock(blockStr, block, ctx); } + compileTIfBranch(content, block, ctx) { + this.target.indentLevel++; + let childN = block.children.length; + this.compileAST(content, createContext(ctx, { block, index: ctx.index })); + if (block.children.length > childN) { + // we have some content => need to insert an anchor at correct index + this.insertAnchor(block, childN); + } + this.target.indentLevel--; + } compileTIf(ast, ctx, nextNode) { - let { block, forceNewBlock, index } = ctx; - let currentIndex = index; + let { block, forceNewBlock } = ctx; const codeIdx = this.target.code.length; const isNewBlock = !block || (block.type !== "multi" && forceNewBlock); if (block) { @@ -4101,28 +4110,16 @@ block = this.createBlock(block, "multi", ctx); } this.addLine(`if (${compileExpr(ast.condition)}) {`); - this.target.indentLevel++; - this.insertAnchor(block); - const subCtx = createContext(ctx, { block, index: currentIndex }); - this.compileAST(ast.content, subCtx); - this.target.indentLevel--; + this.compileTIfBranch(ast.content, block, ctx); if (ast.tElif) { for (let clause of ast.tElif) { this.addLine(`} else if (${compileExpr(clause.condition)}) {`); - this.target.indentLevel++; - this.insertAnchor(block); - const subCtx = createContext(ctx, { block, index: currentIndex }); - this.compileAST(clause.content, subCtx); - this.target.indentLevel--; + this.compileTIfBranch(clause.content, block, ctx); } } if (ast.tElse) { this.addLine(`} else {`); - this.target.indentLevel++; - this.insertAnchor(block); - const subCtx = createContext(ctx, { block, index: currentIndex }); - this.compileAST(ast.tElse, subCtx); - this.target.indentLevel--; + this.compileTIfBranch(ast.tElse, block, ctx); } this.addLine("}"); if (isNewBlock) { @@ -5758,9 +5755,9 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration Object.defineProperty(exports, '__esModule', { value: true }); - __info__.version = '2.0.0-beta-11'; - __info__.date = '2022-06-28T13:35:43.224Z'; - __info__.hash = '76c389a'; + __info__.version = '2.0.0-beta-12'; + __info__.date = '2022-06-29T09:13:44.802Z'; + __info__.hash = '6c72e0a'; __info__.url = 'https://github.com/odoo/owl';