mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] update owl to v1.3.0
This commit is contained in:
@@ -1830,7 +1830,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node.nodeName !== "t") {
|
if (node.nodeName !== "t" || node.hasAttribute("t-tag")) {
|
||||||
let nodeID = this._compileGenericNode(node, ctx, withHandlers);
|
let nodeID = this._compileGenericNode(node, ctx, withHandlers);
|
||||||
ctx = ctx.withParent(nodeID);
|
ctx = ctx.withParent(nodeID);
|
||||||
let nodeHooks = {};
|
let nodeHooks = {};
|
||||||
@@ -2043,7 +2043,14 @@
|
|||||||
ctx.addLine(`}`);
|
ctx.addLine(`}`);
|
||||||
ctx.closeIf();
|
ctx.closeIf();
|
||||||
}
|
}
|
||||||
ctx.addLine(`let vn${nodeID} = h('${node.nodeName}', p${nodeID}, c${nodeID});`);
|
let nodeName = `'${node.nodeName}'`;
|
||||||
|
if (node.hasAttribute("t-tag")) {
|
||||||
|
const tagExpr = node.getAttribute("t-tag");
|
||||||
|
node.removeAttribute("t-tag");
|
||||||
|
nodeName = `tag${ctx.generateID()}`;
|
||||||
|
ctx.addLine(`let ${nodeName} = ${ctx.formatExpression(tagExpr)};`);
|
||||||
|
}
|
||||||
|
ctx.addLine(`let vn${nodeID} = h(${nodeName}, p${nodeID}, c${nodeID});`);
|
||||||
if (ctx.parentNode) {
|
if (ctx.parentNode) {
|
||||||
ctx.addLine(`c${ctx.parentNode}.push(vn${nodeID});`);
|
ctx.addLine(`c${ctx.parentNode}.push(vn${nodeID});`);
|
||||||
}
|
}
|
||||||
@@ -2068,6 +2075,7 @@
|
|||||||
att: 1,
|
att: 1,
|
||||||
attf: 1,
|
attf: 1,
|
||||||
translation: 1,
|
translation: 1,
|
||||||
|
tag: 1,
|
||||||
};
|
};
|
||||||
QWeb.DIRECTIVES = [];
|
QWeb.DIRECTIVES = [];
|
||||||
QWeb.TEMPLATES = {};
|
QWeb.TEMPLATES = {};
|
||||||
@@ -5147,6 +5155,7 @@
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const paramRegexp = /\{\{(.*?)\}\}/;
|
const paramRegexp = /\{\{(.*?)\}\}/;
|
||||||
|
const globalParamRegexp = new RegExp(paramRegexp.source, "g");
|
||||||
class Router {
|
class Router {
|
||||||
constructor(env, routes, options = { mode: "history" }) {
|
constructor(env, routes, options = { mode: "history" }) {
|
||||||
this.currentRoute = null;
|
this.currentRoute = null;
|
||||||
@@ -5168,6 +5177,7 @@
|
|||||||
this.validateDestination(partialRoute.redirect);
|
this.validateDestination(partialRoute.redirect);
|
||||||
}
|
}
|
||||||
partialRoute.params = partialRoute.path ? findParams(partialRoute.path) : [];
|
partialRoute.params = partialRoute.path ? findParams(partialRoute.path) : [];
|
||||||
|
partialRoute.extractionRegExp = makeExtractionRegExp(partialRoute.path);
|
||||||
this.routes[partialRoute.name] = partialRoute;
|
this.routes[partialRoute.name] = partialRoute;
|
||||||
this.routeIds.push(partialRoute.name);
|
this.routeIds.push(partialRoute.name);
|
||||||
}
|
}
|
||||||
@@ -5242,19 +5252,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
routeToPath(route, params) {
|
routeToPath(route, params) {
|
||||||
const path = route.path;
|
|
||||||
const parts = path.split("/");
|
|
||||||
const l = parts.length;
|
|
||||||
for (let i = 0; i < l; i++) {
|
|
||||||
const part = parts[i];
|
|
||||||
const match = part.match(paramRegexp);
|
|
||||||
if (match) {
|
|
||||||
const key = match[1].split(".")[0];
|
|
||||||
parts[i] = params[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const prefix = this.mode === "hash" ? "#" : "";
|
const prefix = this.mode === "hash" ? "#" : "";
|
||||||
return prefix + parts.join("/");
|
return (prefix +
|
||||||
|
route.path.replace(globalParamRegexp, (match, param) => {
|
||||||
|
const [key] = param.split(".");
|
||||||
|
return params[key];
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
currentPath() {
|
currentPath() {
|
||||||
let result = this.mode === "history" ? window.location.pathname : window.location.hash.slice(1);
|
let result = this.mode === "history" ? window.location.pathname : window.location.hash.slice(1);
|
||||||
@@ -5311,42 +5314,46 @@
|
|||||||
if (path.startsWith("#")) {
|
if (path.startsWith("#")) {
|
||||||
path = path.slice(1);
|
path = path.slice(1);
|
||||||
}
|
}
|
||||||
const descrParts = route.path.split("/");
|
const paramsMatch = path.match(route.extractionRegExp);
|
||||||
const targetParts = path.split("/");
|
if (!paramsMatch) {
|
||||||
const l = descrParts.length;
|
|
||||||
if (l !== targetParts.length) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const result = {};
|
const result = {};
|
||||||
for (let i = 0; i < l; i++) {
|
route.params.forEach((param, index) => {
|
||||||
const descr = descrParts[i];
|
const [key, suffix] = param.split(".");
|
||||||
let target = targetParts[i];
|
const paramValue = paramsMatch[index + 1];
|
||||||
const match = descr.match(paramRegexp);
|
if (suffix === "number") {
|
||||||
if (match) {
|
return (result[key] = parseInt(paramValue, 10));
|
||||||
const [key, suffix] = match[1].split(".");
|
|
||||||
if (suffix === "number") {
|
|
||||||
target = parseInt(target, 10);
|
|
||||||
}
|
|
||||||
result[key] = target;
|
|
||||||
}
|
}
|
||||||
else if (descr !== target) {
|
return (result[key] = paramValue);
|
||||||
return false;
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function findParams(str) {
|
function findParams(str) {
|
||||||
const globalParamRegexp = /\{\{(.*?)\}\}/g;
|
|
||||||
const result = [];
|
const result = [];
|
||||||
let m;
|
let m;
|
||||||
do {
|
do {
|
||||||
m = globalParamRegexp.exec(str);
|
m = globalParamRegexp.exec(str);
|
||||||
if (m) {
|
if (m) {
|
||||||
result.push(m[1].split(".")[0]);
|
result.push(m[1]);
|
||||||
}
|
}
|
||||||
} while (m);
|
} while (m);
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
|
function escapeRegExp(str) {
|
||||||
|
return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
||||||
|
}
|
||||||
|
function makeExtractionRegExp(path) {
|
||||||
|
// replace param strings with capture groups so that we can build a regex to match over the path
|
||||||
|
const extractionString = path
|
||||||
|
.split(paramRegexp)
|
||||||
|
.map((part, index) => {
|
||||||
|
return index % 2 ? "(.*)" : escapeRegExp(part);
|
||||||
|
})
|
||||||
|
.join("");
|
||||||
|
// Example: /home/{{param1}}/{{param2}} => ^\/home\/(.*)\/(.*)$
|
||||||
|
return new RegExp(`^${extractionString}$`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -5388,9 +5395,9 @@
|
|||||||
exports.utils = utils;
|
exports.utils = utils;
|
||||||
|
|
||||||
|
|
||||||
__info__.version = '1.2.5';
|
__info__.version = '1.3.0';
|
||||||
__info__.date = '2021-05-18T08:01:47.651Z';
|
__info__.date = '2021-06-04T12:19:29.161Z';
|
||||||
__info__.hash = '968a546';
|
__info__.hash = '9cbcf20';
|
||||||
__info__.url = 'https://github.com/odoo/owl';
|
__info__.url = 'https://github.com/odoo/owl';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user