Skip to content

Commit

Permalink
[REL] v2.2.5
Browse files Browse the repository at this point in the history
# v2.2.5

 - [FIX] compiler: fix xmlns attribute not being set correctly in firefox
 - [FIX] compiler: fix t-call at root of template causing crashes
 - [REF] compiler: minor cleanup
 - [FIX] devtools: fix inspected path
  • Loading branch information
sdegueldre committed Aug 7, 2023
1 parent b25e988 commit 4b23f51
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 50 deletions.
86 changes: 39 additions & 47 deletions docs/owl.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,7 @@ function buildTree(node, parent = null, domParentTree = null) {
info.push({ type: "child", idx: index });
el = document.createTextNode("");
}
const attrs = node.attributes;
const ns = attrs.getNamedItem("block-ns");
if (ns) {
attrs.removeNamedItem("block-ns");
currentNS = ns.value;
}
currentNS || (currentNS = node.namespaceURI);
if (!el) {
el = currentNS
? document.createElementNS(currentNS, tagName)
Expand All @@ -731,6 +726,7 @@ function buildTree(node, parent = null, domParentTree = null) {
const fragment = document.createElement("template").content;
fragment.appendChild(el);
}
const attrs = node.attributes;
for (let i = 0; i < attrs.length; i++) {
const attrName = attrs[i].name;
const attrValue = attrs[i].value;
Expand Down Expand Up @@ -3854,7 +3850,7 @@ class CodeGenerator {
createBlock(parentBlock, type, ctx) {
const hasRoot = this.target.hasRoot;
const block = new BlockDescription(this.target, type);
if (!hasRoot && !ctx.preventRoot) {
if (!hasRoot) {
this.target.hasRoot = true;
block.isRoot = true;
}
Expand All @@ -3877,7 +3873,7 @@ class CodeGenerator {
if (ctx.tKeyExpr) {
blockExpr = `toggler(${ctx.tKeyExpr}, ${blockExpr})`;
}
if (block.isRoot && !ctx.preventRoot) {
if (block.isRoot) {
if (this.target.on) {
blockExpr = this.wrapWithEventCatcher(blockExpr, this.target.on);
}
Expand Down Expand Up @@ -4053,11 +4049,6 @@ class CodeGenerator {
}
// attributes
const attrs = {};
const nameSpace = ast.ns || ctx.nameSpace;
if (nameSpace && isNewBlock) {
// specific namespace uri
attrs["block-ns"] = nameSpace;
}
for (let key in ast.attrs) {
let expr, attrName;
if (key.startsWith("t-attf")) {
Expand Down Expand Up @@ -4173,7 +4164,10 @@ class CodeGenerator {
const idx = block.insertData(setRefStr, "ref");
attrs["block-ref"] = String(idx);
}
const dom = xmlDoc.createElement(ast.tag);
const nameSpace = ast.ns || ctx.nameSpace;
const dom = nameSpace
? xmlDoc.createElementNS(nameSpace, ast.tag)
: xmlDoc.createElement(ast.tag);
for (const [attr, val] of Object.entries(attrs)) {
if (!(attr === "class" && val === "")) {
dom.setAttribute(attr, val);
Expand Down Expand Up @@ -4215,7 +4209,7 @@ class CodeGenerator {
break;
}
}
this.addLine(`let ${block.children.map((c) => c.varName)};`, codeIdx);
this.addLine(`let ${block.children.map((c) => c.varName).join(", ")};`, codeIdx);
}
}
return block.varName;
Expand Down Expand Up @@ -4318,7 +4312,7 @@ class CodeGenerator {
break;
}
}
this.addLine(`let ${block.children.map((c) => c.varName)};`, codeIdx);
this.addLine(`let ${block.children.map((c) => c.varName).join(", ")};`, codeIdx);
}
// note: this part is duplicated from end of compilemulti:
const args = block.children.map((c) => c.varName).join(", ");
Expand Down Expand Up @@ -4433,7 +4427,6 @@ class CodeGenerator {
block,
index,
forceNewBlock: !isTSet,
preventRoot: ctx.preventRoot,
isLast: ctx.isLast && i === l - 1,
});
this.compileAST(child, subCtx);
Expand All @@ -4442,21 +4435,19 @@ class CodeGenerator {
}
}
if (isNewBlock) {
if (block.hasDynamicChildren) {
if (block.children.length) {
const code = this.target.code;
const children = block.children.slice();
let current = children.shift();
for (let i = codeIdx; i < code.length; i++) {
if (code[i].trimStart().startsWith(`const ${current.varName} `)) {
code[i] = code[i].replace(`const ${current.varName}`, current.varName);
current = children.shift();
if (!current)
break;
}
if (block.hasDynamicChildren && block.children.length) {
const code = this.target.code;
const children = block.children.slice();
let current = children.shift();
for (let i = codeIdx; i < code.length; i++) {
if (code[i].trimStart().startsWith(`const ${current.varName} `)) {
code[i] = code[i].replace(`const ${current.varName}`, current.varName);
current = children.shift();
if (!current)
break;
}
this.addLine(`let ${block.children.map((c) => c.varName)};`, codeIdx);
}
this.addLine(`let ${block.children.map((c) => c.varName).join(", ")};`, codeIdx);
}
const args = block.children.map((c) => c.varName).join(", ");
this.insertBlock(`multi([${args}])`, block, ctx);
Expand All @@ -4470,32 +4461,30 @@ class CodeGenerator {
ctxVar = generateId("ctx");
this.addLine(`let ${ctxVar} = ${compileExpr(ast.context)};`);
}
const isDynamic = INTERP_REGEXP.test(ast.name);
const subTemplate = isDynamic ? interpolate(ast.name) : "`" + ast.name + "`";
if (block && !forceNewBlock) {
this.insertAnchor(block);
}
block = this.createBlock(block, "multi", ctx);
if (ast.body) {
this.addLine(`${ctxVar} = Object.create(${ctxVar});`);
this.addLine(`${ctxVar}[isBoundary] = 1;`);
this.helpers.add("isBoundary");
const subCtx = createContext(ctx, { preventRoot: true, ctxVar });
const subCtx = createContext(ctx, { ctxVar });
const bl = this.compileMulti({ type: 3 /* Multi */, content: ast.body }, subCtx);
if (bl) {
this.helpers.add("zero");
this.addLine(`${ctxVar}[zero] = ${bl};`);
}
}
const isDynamic = INTERP_REGEXP.test(ast.name);
const subTemplate = isDynamic ? interpolate(ast.name) : "`" + ast.name + "`";
if (block) {
if (!forceNewBlock) {
this.insertAnchor(block);
}
}
const key = `key + \`${this.generateComponentKey()}\``;
if (isDynamic) {
const templateVar = generateId("template");
if (!this.staticDefs.find((d) => d.id === "call")) {
this.staticDefs.push({ id: "call", expr: `app.callTemplate.bind(app)` });
}
this.define(templateVar, subTemplate);
block = this.createBlock(block, "multi", ctx);
this.insertBlock(`call(this, ${templateVar}, ${ctxVar}, node, ${key})`, block, {
...ctx,
forceNewBlock: !block,
Expand All @@ -4504,7 +4493,6 @@ class CodeGenerator {
else {
const id = generateId(`callTemplate_`);
this.staticDefs.push({ id, expr: `app.getTemplate(${subTemplate})` });
block = this.createBlock(block, "multi", ctx);
this.insertBlock(`${id}.call(this, ${ctxVar}, node, ${key})`, block, {
...ctx,
forceNewBlock: !block,
Expand Down Expand Up @@ -4826,7 +4814,7 @@ function parse(xml) {
}
function _parse(xml) {
normalizeXML(xml);
const ctx = { inPreTag: false, inSVG: false };
const ctx = { inPreTag: false };
return parseNode(xml, ctx) || { type: 0 /* Text */, value: "" };
}
function parseNode(node, ctx) {
Expand Down Expand Up @@ -4917,9 +4905,7 @@ function parseDOMNode(node, ctx) {
if (tagName === "pre") {
ctx.inPreTag = true;
}
const shouldAddSVGNS = ROOT_SVG_TAGS.has(tagName) && !ctx.inSVG;
ctx.inSVG = ctx.inSVG || shouldAddSVGNS;
const ns = shouldAddSVGNS ? "http://www.w3.org/2000/svg" : null;
let ns = !ctx.nameSpace && ROOT_SVG_TAGS.has(tagName) ? "http://www.w3.org/2000/svg" : null;
const ref = node.getAttribute("t-ref");
node.removeAttribute("t-ref");
const nodeAttrsNames = node.getAttributeNames();
Expand Down Expand Up @@ -4981,6 +4967,9 @@ function parseDOMNode(node, ctx) {
else if (attr.startsWith("block-")) {
throw new OwlError(`Invalid attribute: '${attr}'`);
}
else if (attr === "xmlns") {
ns = value;
}
else if (attr !== "t-name") {
if (attr.startsWith("t-") && !attr.startsWith("t-att")) {
throw new OwlError(`Unknown QWeb directive: '${attr}'`);
Expand All @@ -4993,6 +4982,9 @@ function parseDOMNode(node, ctx) {
attrs[attr] = value;
}
}
if (ns) {
ctx.nameSpace = ns;
}
const children = parseChildren(node, ctx);
return {
type: 2 /* DomNode */,
Expand Down Expand Up @@ -5561,7 +5553,7 @@ function compile(template, options = {}) {
}

// do not modify manually. This file is generated by the release script.
const version = "2.2.4";
const version = "2.2.5";

// -----------------------------------------------------------------------------
// Scheduler
Expand Down Expand Up @@ -5994,6 +5986,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 };


__info__.date = '2023-08-02T06:20:03.634Z';
__info__.hash = '8f9ad98';
__info__.date = '2023-08-07T10:26:30.557Z';
__info__.hash = 'b25e988';
__info__.url = 'https://github.com/odoo/owl';
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@odoo/owl",
"version": "2.2.4",
"version": "2.2.5",
"description": "Odoo Web Library (OWL)",
"main": "dist/owl.cjs.js",
"module": "dist/owl.es.js",
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// do not modify manually. This file is generated by the release script.
export const version = "2.2.4";
export const version = "2.2.5";

0 comments on commit 4b23f51

Please sign in to comment.