From 3bf76fcb9ee4941e40aa69e40a2ce47a45ce3d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 26 Jun 2023 09:34:58 +0000 Subject: [PATCH] [IMP] web: update owl to 2.1.4 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.1.4 This release contains mostly devtools improvements, but there are three small bug fixes as well: [FIX] blockdom: properly merge dynamic class values [FIX] parser: make t-on stricter [FIX] compiler: apply translations to t-set text body closes odoo/odoo#126755 X-original-commit: b26a66d928aad283c7ec17d767c6bc1e42e24206 Signed-off-by: Nicolas Seinlet (nse) Signed-off-by: Géry Debongnie --- addons/web/static/lib/owl/owl.js | 68 +++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/addons/web/static/lib/owl/owl.js b/addons/web/static/lib/owl/owl.js index a91b396cabe..fc72be68e18 100644 --- a/addons/web/static/lib/owl/owl.js +++ b/addons/web/static/lib/owl/owl.js @@ -178,11 +178,21 @@ } function attrsSetter(attrs) { if (isArray(attrs)) { - setAttribute.call(this, attrs[0], attrs[1]); + if (attrs[0] === "class") { + setClass.call(this, attrs[1]); + } + else { + setAttribute.call(this, attrs[0], attrs[1]); + } } else { for (let k in attrs) { - setAttribute.call(this, k, attrs[k]); + if (k === "class") { + setClass.call(this, attrs[k]); + } + else { + setAttribute.call(this, k, attrs[k]); + } } } } @@ -194,7 +204,12 @@ if (val === oldAttrs[1]) { return; } - setAttribute.call(this, name, val); + if (name === "class") { + updateClass.call(this, val, oldAttrs[1]); + } + else { + setAttribute.call(this, name, val); + } } else { removeAttribute.call(this, oldAttrs[0]); @@ -204,13 +219,23 @@ else { for (let k in oldAttrs) { if (!(k in attrs)) { - removeAttribute.call(this, k); + if (k === "class") { + updateClass.call(this, "", oldAttrs[k]); + } + else { + removeAttribute.call(this, k); + } } } for (let k in attrs) { const val = attrs[k]; if (val !== oldAttrs[k]) { - setAttribute.call(this, k, val); + if (k === "class") { + updateClass.call(this, val, oldAttrs[k]); + } + else { + setAttribute.call(this, k, val); + } } } } @@ -3878,6 +3903,10 @@ }) .join(""); } + translate(str) { + const match = translationRE.exec(str); + return match[1] + this.translateFn(match[2]) + match[3]; + } /** * @returns the newly created block name, if any */ @@ -3955,8 +3984,7 @@ let { block, forceNewBlock } = ctx; let value = ast.value; if (value && ctx.translate !== false) { - const match = translationRE.exec(value); - value = match[1] + this.translateFn(match[2]) + match[3]; + value = this.translate(value); } if (!ctx.inPreTag) { value = value.replace(whitespaceRE, " "); @@ -4497,11 +4525,12 @@ else { let value; if (ast.defaultValue) { + const defaultValue = ctx.translate ? this.translate(ast.defaultValue) : ast.defaultValue; if (ast.value) { - value = `withDefault(${expr}, \`${ast.defaultValue}\`)`; + value = `withDefault(${expr}, \`${defaultValue}\`)`; } else { - value = `\`${ast.defaultValue}\``; + value = `\`${defaultValue}\``; } } else { @@ -4882,10 +4911,10 @@ let model = null; for (let attr of nodeAttrsNames) { const value = node.getAttribute(attr); - if (attr.startsWith("t-on")) { - if (attr === "t-on") { - throw new OwlError("Missing event name with t-on directive"); - } + if (attr === "t-on" || attr === "t-on-") { + throw new OwlError("Missing event name with t-on directive"); + } + if (attr.startsWith("t-on-")) { on = on || {}; on[attr.slice(5)] = value; } @@ -5509,7 +5538,7 @@ } // do not modify manually. This file is generated by the release script. - const version = "2.1.3"; + const version = "2.1.4"; // ----------------------------------------------------------------------------- // Scheduler @@ -5588,6 +5617,8 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration apps: new Set(), Fiber: Fiber, RootFiber: RootFiber, + toRaw: toRaw, + reactive: reactive, }); class App extends TemplateSet { constructor(Root, config = {}) { @@ -5840,8 +5871,9 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration * will run a cleanup function before patching and before unmounting the * the component. * - * @param {Effect} effect the effect to run on component mount and/or patch - * @param {()=>any[]} [computeDependencies=()=>[NaN]] a callback to compute + * @template T + * @param {Effect} effect the effect to run on component mount and/or patch + * @param {()=>T} [computeDependencies=()=>[NaN]] a callback to compute * dependencies that will decide if the effect needs to be cleaned up and * run again. If the dependencies did not change, the effect will not run * again. The default value returns an array containing only NaN because @@ -5959,8 +5991,8 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration Object.defineProperty(exports, '__esModule', { value: true }); - __info__.date = '2023-04-29T07:46:30.326Z'; - __info__.hash = 'ba20267'; + __info__.date = '2023-06-28T09:34:39.893Z'; + __info__.hash = '3001420'; __info__.url = 'https://github.com/odoo/owl';