[REL] v2.1.4

# v2.1.3

 - [FIX] components: properly differentiate t-call subcomponents
 - [REF] devtools: Better messages forwarding
 - [FIX] devtools: Fix app methods patching
 - [DOC] Fix a code bug in the example of slots
This commit is contained in:
Géry Debongnie
2023-06-28 11:17:24 +02:00
parent 432ff444a1
commit 3001420a1d
4 changed files with 53 additions and 21 deletions
+43 -11
View File
@@ -175,13 +175,23 @@ function createAttrUpdater(attr) {
} }
function attrsSetter(attrs) { function attrsSetter(attrs) {
if (isArray(attrs)) { if (isArray(attrs)) {
if (attrs[0] === "class") {
setClass.call(this, attrs[1]);
}
else {
setAttribute.call(this, attrs[0], attrs[1]); setAttribute.call(this, attrs[0], attrs[1]);
} }
}
else { else {
for (let k in attrs) { for (let k in attrs) {
if (k === "class") {
setClass.call(this, attrs[k]);
}
else {
setAttribute.call(this, k, attrs[k]); setAttribute.call(this, k, attrs[k]);
} }
} }
}
} }
function attrsUpdater(attrs, oldAttrs) { function attrsUpdater(attrs, oldAttrs) {
if (isArray(attrs)) { if (isArray(attrs)) {
@@ -191,8 +201,13 @@ function attrsUpdater(attrs, oldAttrs) {
if (val === oldAttrs[1]) { if (val === oldAttrs[1]) {
return; return;
} }
if (name === "class") {
updateClass.call(this, val, oldAttrs[1]);
}
else {
setAttribute.call(this, name, val); setAttribute.call(this, name, val);
} }
}
else { else {
removeAttribute.call(this, oldAttrs[0]); removeAttribute.call(this, oldAttrs[0]);
setAttribute.call(this, name, val); setAttribute.call(this, name, val);
@@ -201,16 +216,26 @@ function attrsUpdater(attrs, oldAttrs) {
else { else {
for (let k in oldAttrs) { for (let k in oldAttrs) {
if (!(k in attrs)) { if (!(k in attrs)) {
if (k === "class") {
updateClass.call(this, "", oldAttrs[k]);
}
else {
removeAttribute.call(this, k); removeAttribute.call(this, k);
} }
} }
}
for (let k in attrs) { for (let k in attrs) {
const val = attrs[k]; const val = attrs[k];
if (val !== oldAttrs[k]) { if (val !== oldAttrs[k]) {
if (k === "class") {
updateClass.call(this, val, oldAttrs[k]);
}
else {
setAttribute.call(this, k, val); setAttribute.call(this, k, val);
} }
} }
} }
}
} }
function toClassObj(expr) { function toClassObj(expr) {
const result = {}; const result = {};
@@ -3875,6 +3900,10 @@ class CodeGenerator {
}) })
.join(""); .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 * @returns the newly created block name, if any
*/ */
@@ -3952,8 +3981,7 @@ class CodeGenerator {
let { block, forceNewBlock } = ctx; let { block, forceNewBlock } = ctx;
let value = ast.value; let value = ast.value;
if (value && ctx.translate !== false) { if (value && ctx.translate !== false) {
const match = translationRE.exec(value); value = this.translate(value);
value = match[1] + this.translateFn(match[2]) + match[3];
} }
if (!ctx.inPreTag) { if (!ctx.inPreTag) {
value = value.replace(whitespaceRE, " "); value = value.replace(whitespaceRE, " ");
@@ -4494,11 +4522,12 @@ class CodeGenerator {
else { else {
let value; let value;
if (ast.defaultValue) { if (ast.defaultValue) {
const defaultValue = ctx.translate ? this.translate(ast.defaultValue) : ast.defaultValue;
if (ast.value) { if (ast.value) {
value = `withDefault(${expr}, \`${ast.defaultValue}\`)`; value = `withDefault(${expr}, \`${defaultValue}\`)`;
} }
else { else {
value = `\`${ast.defaultValue}\``; value = `\`${defaultValue}\``;
} }
} }
else { else {
@@ -4879,10 +4908,10 @@ function parseDOMNode(node, ctx) {
let model = null; let model = null;
for (let attr of nodeAttrsNames) { for (let attr of nodeAttrsNames) {
const value = node.getAttribute(attr); const value = node.getAttribute(attr);
if (attr.startsWith("t-on")) { if (attr === "t-on" || attr === "t-on-") {
if (attr === "t-on") {
throw new OwlError("Missing event name with t-on directive"); throw new OwlError("Missing event name with t-on directive");
} }
if (attr.startsWith("t-on-")) {
on = on || {}; on = on || {};
on[attr.slice(5)] = value; on[attr.slice(5)] = value;
} }
@@ -5506,7 +5535,7 @@ function compile(template, options = {}) {
} }
// do not modify manually. This file is generated by the release script. // do not modify manually. This file is generated by the release script.
const version = "2.1.2"; const version = "2.1.3";
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Scheduler // Scheduler
@@ -5585,6 +5614,8 @@ window.__OWL_DEVTOOLS__ || (window.__OWL_DEVTOOLS__ = {
apps: new Set(), apps: new Set(),
Fiber: Fiber, Fiber: Fiber,
RootFiber: RootFiber, RootFiber: RootFiber,
toRaw: toRaw,
reactive: reactive,
}); });
class App extends TemplateSet { class App extends TemplateSet {
constructor(Root, config = {}) { constructor(Root, config = {}) {
@@ -5837,8 +5868,9 @@ function useChildSubEnv(envExtension) {
* will run a cleanup function before patching and before unmounting the * will run a cleanup function before patching and before unmounting the
* the component. * the component.
* *
* @param {Effect} effect the effect to run on component mount and/or patch * @template T
* @param {()=>any[]} [computeDependencies=()=>[NaN]] a callback to compute * @param {Effect<T>} 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 * 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 * run again. If the dependencies did not change, the effect will not run
* again. The default value returns an array containing only NaN because * again. The default value returns an array containing only NaN because
@@ -5920,6 +5952,6 @@ TemplateSet.prototype._compileTemplate = function _compileTemplate(name, templat
export { App, Component, EventBus, OwlError, __info__, blockDom, loadFile, markRaw, markup, mount, onError, onMounted, onPatched, onRendered, onWillDestroy, onWillPatch, onWillRender, onWillStart, onWillUnmount, onWillUpdateProps, reactive, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, useRef, useState, useSubEnv, validate, validateType, whenReady, xml }; export { App, Component, EventBus, OwlError, __info__, blockDom, loadFile, markRaw, markup, mount, onError, onMounted, onPatched, onRendered, onWillDestroy, onWillPatch, onWillRender, onWillStart, onWillUnmount, onWillUpdateProps, reactive, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, useRef, useState, useSubEnv, validate, validateType, whenReady, xml };
__info__.date = '2023-04-29T07:45:54.333Z'; __info__.date = '2023-06-28T09:17:13.630Z';
__info__.hash = 'aabb755'; __info__.hash = '432ff44';
__info__.url = 'https://github.com/odoo/owl'; __info__.url = 'https://github.com/odoo/owl';
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@odoo/owl", "name": "@odoo/owl",
"version": "2.1.3", "version": "2.1.4",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@odoo/owl", "name": "@odoo/owl",
"version": "2.1.3", "version": "2.1.4",
"description": "Odoo Web Library (OWL)", "description": "Odoo Web Library (OWL)",
"main": "dist/owl.cjs.js", "main": "dist/owl.cjs.js",
"module": "dist/owl.es.js", "module": "dist/owl.es.js",
+1 -1
View File
@@ -1,2 +1,2 @@
// do not modify manually. This file is generated by the release script. // do not modify manually. This file is generated by the release script.
export const version = "2.1.3"; export const version = "2.1.4";