@odoo/owl 2.2.4 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/owl.iife.js CHANGED
@@ -713,12 +713,7 @@
713
713
  info.push({ type: "child", idx: index });
714
714
  el = document.createTextNode("");
715
715
  }
716
- const attrs = node.attributes;
717
- const ns = attrs.getNamedItem("block-ns");
718
- if (ns) {
719
- attrs.removeNamedItem("block-ns");
720
- currentNS = ns.value;
721
- }
716
+ currentNS || (currentNS = node.namespaceURI);
722
717
  if (!el) {
723
718
  el = currentNS
724
719
  ? document.createElementNS(currentNS, tagName)
@@ -734,6 +729,7 @@
734
729
  const fragment = document.createElement("template").content;
735
730
  fragment.appendChild(el);
736
731
  }
732
+ const attrs = node.attributes;
737
733
  for (let i = 0; i < attrs.length; i++) {
738
734
  const attrName = attrs[i].name;
739
735
  const attrValue = attrs[i].value;
@@ -2184,7 +2180,7 @@
2184
2180
  if (hadKey !== hasKey) {
2185
2181
  notifyReactives(target, KEYCHANGES);
2186
2182
  }
2187
- if (originalValue !== value) {
2183
+ if (originalValue !== target[getterName](key)) {
2188
2184
  notifyReactives(target, key);
2189
2185
  }
2190
2186
  return ret;
@@ -3005,15 +3001,13 @@
3005
3001
  keys = [...collection.keys()];
3006
3002
  values = [...collection.values()];
3007
3003
  }
3004
+ else if (Symbol.iterator in Object(collection)) {
3005
+ keys = [...collection];
3006
+ values = keys;
3007
+ }
3008
3008
  else if (collection && typeof collection === "object") {
3009
- if (Symbol.iterator in collection) {
3010
- keys = [...collection];
3011
- values = keys;
3012
- }
3013
- else {
3014
- values = Object.values(collection);
3015
- keys = Object.keys(collection);
3016
- }
3009
+ values = Object.values(collection);
3010
+ keys = Object.keys(collection);
3017
3011
  }
3018
3012
  else {
3019
3013
  throw new OwlError(`Invalid loop expression: "${collection}" is not iterable`);
@@ -3214,6 +3208,10 @@
3214
3208
  }
3215
3209
  addTemplate(name, template) {
3216
3210
  if (name in this.rawTemplates) {
3211
+ // this check can be expensive, just silently ignore double definitions outside dev mode
3212
+ if (!this.dev) {
3213
+ return;
3214
+ }
3217
3215
  const rawTemplate = this.rawTemplates[name];
3218
3216
  const currentAsString = typeof rawTemplate === "string"
3219
3217
  ? rawTemplate
@@ -3857,7 +3855,7 @@
3857
3855
  createBlock(parentBlock, type, ctx) {
3858
3856
  const hasRoot = this.target.hasRoot;
3859
3857
  const block = new BlockDescription(this.target, type);
3860
- if (!hasRoot && !ctx.preventRoot) {
3858
+ if (!hasRoot) {
3861
3859
  this.target.hasRoot = true;
3862
3860
  block.isRoot = true;
3863
3861
  }
@@ -3880,7 +3878,7 @@
3880
3878
  if (ctx.tKeyExpr) {
3881
3879
  blockExpr = `toggler(${ctx.tKeyExpr}, ${blockExpr})`;
3882
3880
  }
3883
- if (block.isRoot && !ctx.preventRoot) {
3881
+ if (block.isRoot) {
3884
3882
  if (this.target.on) {
3885
3883
  blockExpr = this.wrapWithEventCatcher(blockExpr, this.target.on);
3886
3884
  }
@@ -4056,11 +4054,6 @@
4056
4054
  }
4057
4055
  // attributes
4058
4056
  const attrs = {};
4059
- const nameSpace = ast.ns || ctx.nameSpace;
4060
- if (nameSpace && isNewBlock) {
4061
- // specific namespace uri
4062
- attrs["block-ns"] = nameSpace;
4063
- }
4064
4057
  for (let key in ast.attrs) {
4065
4058
  let expr, attrName;
4066
4059
  if (key.startsWith("t-attf")) {
@@ -4176,7 +4169,10 @@
4176
4169
  const idx = block.insertData(setRefStr, "ref");
4177
4170
  attrs["block-ref"] = String(idx);
4178
4171
  }
4179
- const dom = xmlDoc.createElement(ast.tag);
4172
+ const nameSpace = ast.ns || ctx.nameSpace;
4173
+ const dom = nameSpace
4174
+ ? xmlDoc.createElementNS(nameSpace, ast.tag)
4175
+ : xmlDoc.createElement(ast.tag);
4180
4176
  for (const [attr, val] of Object.entries(attrs)) {
4181
4177
  if (!(attr === "class" && val === "")) {
4182
4178
  dom.setAttribute(attr, val);
@@ -4218,7 +4214,7 @@
4218
4214
  break;
4219
4215
  }
4220
4216
  }
4221
- this.addLine(`let ${block.children.map((c) => c.varName)};`, codeIdx);
4217
+ this.addLine(`let ${block.children.map((c) => c.varName).join(", ")};`, codeIdx);
4222
4218
  }
4223
4219
  }
4224
4220
  return block.varName;
@@ -4321,7 +4317,7 @@
4321
4317
  break;
4322
4318
  }
4323
4319
  }
4324
- this.addLine(`let ${block.children.map((c) => c.varName)};`, codeIdx);
4320
+ this.addLine(`let ${block.children.map((c) => c.varName).join(", ")};`, codeIdx);
4325
4321
  }
4326
4322
  // note: this part is duplicated from end of compilemulti:
4327
4323
  const args = block.children.map((c) => c.varName).join(", ");
@@ -4436,7 +4432,6 @@
4436
4432
  block,
4437
4433
  index,
4438
4434
  forceNewBlock: !isTSet,
4439
- preventRoot: ctx.preventRoot,
4440
4435
  isLast: ctx.isLast && i === l - 1,
4441
4436
  });
4442
4437
  this.compileAST(child, subCtx);
@@ -4445,21 +4440,19 @@
4445
4440
  }
4446
4441
  }
4447
4442
  if (isNewBlock) {
4448
- if (block.hasDynamicChildren) {
4449
- if (block.children.length) {
4450
- const code = this.target.code;
4451
- const children = block.children.slice();
4452
- let current = children.shift();
4453
- for (let i = codeIdx; i < code.length; i++) {
4454
- if (code[i].trimStart().startsWith(`const ${current.varName} `)) {
4455
- code[i] = code[i].replace(`const ${current.varName}`, current.varName);
4456
- current = children.shift();
4457
- if (!current)
4458
- break;
4459
- }
4443
+ if (block.hasDynamicChildren && block.children.length) {
4444
+ const code = this.target.code;
4445
+ const children = block.children.slice();
4446
+ let current = children.shift();
4447
+ for (let i = codeIdx; i < code.length; i++) {
4448
+ if (code[i].trimStart().startsWith(`const ${current.varName} `)) {
4449
+ code[i] = code[i].replace(`const ${current.varName}`, current.varName);
4450
+ current = children.shift();
4451
+ if (!current)
4452
+ break;
4460
4453
  }
4461
- this.addLine(`let ${block.children.map((c) => c.varName)};`, codeIdx);
4462
4454
  }
4455
+ this.addLine(`let ${block.children.map((c) => c.varName).join(", ")};`, codeIdx);
4463
4456
  }
4464
4457
  const args = block.children.map((c) => c.varName).join(", ");
4465
4458
  this.insertBlock(`multi([${args}])`, block, ctx);
@@ -4473,24 +4466,23 @@
4473
4466
  ctxVar = generateId("ctx");
4474
4467
  this.addLine(`let ${ctxVar} = ${compileExpr(ast.context)};`);
4475
4468
  }
4469
+ const isDynamic = INTERP_REGEXP.test(ast.name);
4470
+ const subTemplate = isDynamic ? interpolate(ast.name) : "`" + ast.name + "`";
4471
+ if (block && !forceNewBlock) {
4472
+ this.insertAnchor(block);
4473
+ }
4474
+ block = this.createBlock(block, "multi", ctx);
4476
4475
  if (ast.body) {
4477
4476
  this.addLine(`${ctxVar} = Object.create(${ctxVar});`);
4478
4477
  this.addLine(`${ctxVar}[isBoundary] = 1;`);
4479
4478
  this.helpers.add("isBoundary");
4480
- const subCtx = createContext(ctx, { preventRoot: true, ctxVar });
4479
+ const subCtx = createContext(ctx, { ctxVar });
4481
4480
  const bl = this.compileMulti({ type: 3 /* Multi */, content: ast.body }, subCtx);
4482
4481
  if (bl) {
4483
4482
  this.helpers.add("zero");
4484
4483
  this.addLine(`${ctxVar}[zero] = ${bl};`);
4485
4484
  }
4486
4485
  }
4487
- const isDynamic = INTERP_REGEXP.test(ast.name);
4488
- const subTemplate = isDynamic ? interpolate(ast.name) : "`" + ast.name + "`";
4489
- if (block) {
4490
- if (!forceNewBlock) {
4491
- this.insertAnchor(block);
4492
- }
4493
- }
4494
4486
  const key = `key + \`${this.generateComponentKey()}\``;
4495
4487
  if (isDynamic) {
4496
4488
  const templateVar = generateId("template");
@@ -4498,7 +4490,6 @@
4498
4490
  this.staticDefs.push({ id: "call", expr: `app.callTemplate.bind(app)` });
4499
4491
  }
4500
4492
  this.define(templateVar, subTemplate);
4501
- block = this.createBlock(block, "multi", ctx);
4502
4493
  this.insertBlock(`call(this, ${templateVar}, ${ctxVar}, node, ${key})`, block, {
4503
4494
  ...ctx,
4504
4495
  forceNewBlock: !block,
@@ -4507,7 +4498,6 @@
4507
4498
  else {
4508
4499
  const id = generateId(`callTemplate_`);
4509
4500
  this.staticDefs.push({ id, expr: `app.getTemplate(${subTemplate})` });
4510
- block = this.createBlock(block, "multi", ctx);
4511
4501
  this.insertBlock(`${id}.call(this, ${ctxVar}, node, ${key})`, block, {
4512
4502
  ...ctx,
4513
4503
  forceNewBlock: !block,
@@ -4829,7 +4819,7 @@
4829
4819
  }
4830
4820
  function _parse(xml) {
4831
4821
  normalizeXML(xml);
4832
- const ctx = { inPreTag: false, inSVG: false };
4822
+ const ctx = { inPreTag: false };
4833
4823
  return parseNode(xml, ctx) || { type: 0 /* Text */, value: "" };
4834
4824
  }
4835
4825
  function parseNode(node, ctx) {
@@ -4920,9 +4910,7 @@
4920
4910
  if (tagName === "pre") {
4921
4911
  ctx.inPreTag = true;
4922
4912
  }
4923
- const shouldAddSVGNS = ROOT_SVG_TAGS.has(tagName) && !ctx.inSVG;
4924
- ctx.inSVG = ctx.inSVG || shouldAddSVGNS;
4925
- const ns = shouldAddSVGNS ? "http://www.w3.org/2000/svg" : null;
4913
+ let ns = !ctx.nameSpace && ROOT_SVG_TAGS.has(tagName) ? "http://www.w3.org/2000/svg" : null;
4926
4914
  const ref = node.getAttribute("t-ref");
4927
4915
  node.removeAttribute("t-ref");
4928
4916
  const nodeAttrsNames = node.getAttributeNames();
@@ -4984,6 +4972,9 @@
4984
4972
  else if (attr.startsWith("block-")) {
4985
4973
  throw new OwlError(`Invalid attribute: '${attr}'`);
4986
4974
  }
4975
+ else if (attr === "xmlns") {
4976
+ ns = value;
4977
+ }
4987
4978
  else if (attr !== "t-name") {
4988
4979
  if (attr.startsWith("t-") && !attr.startsWith("t-att")) {
4989
4980
  throw new OwlError(`Unknown QWeb directive: '${attr}'`);
@@ -4996,6 +4987,9 @@
4996
4987
  attrs[attr] = value;
4997
4988
  }
4998
4989
  }
4990
+ if (ns) {
4991
+ ctx.nameSpace = ns;
4992
+ }
4999
4993
  const children = parseChildren(node, ctx);
5000
4994
  return {
5001
4995
  type: 2 /* DomNode */,
@@ -5564,7 +5558,7 @@
5564
5558
  }
5565
5559
 
5566
5560
  // do not modify manually. This file is generated by the release script.
5567
- const version = "2.2.4";
5561
+ const version = "2.2.6";
5568
5562
 
5569
5563
  // -----------------------------------------------------------------------------
5570
5564
  // Scheduler
@@ -5653,13 +5647,8 @@
5653
5647
  This is not suitable for production use.
5654
5648
  See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration for more information.`;
5655
5649
  };
5656
- window.__OWL_DEVTOOLS__ || (window.__OWL_DEVTOOLS__ = {
5657
- apps: new Set(),
5658
- Fiber: Fiber,
5659
- RootFiber: RootFiber,
5660
- toRaw: toRaw,
5661
- reactive: reactive,
5662
- });
5650
+ const apps = new Set();
5651
+ window.__OWL_DEVTOOLS__ || (window.__OWL_DEVTOOLS__ = { apps, Fiber, RootFiber, toRaw, reactive });
5663
5652
  class App extends TemplateSet {
5664
5653
  constructor(Root, config = {}) {
5665
5654
  super(config);
@@ -5667,7 +5656,7 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
5667
5656
  this.root = null;
5668
5657
  this.name = config.name || "";
5669
5658
  this.Root = Root;
5670
- window.__OWL_DEVTOOLS__.apps.add(this);
5659
+ apps.add(this);
5671
5660
  if (config.test) {
5672
5661
  this.dev = true;
5673
5662
  }
@@ -5724,7 +5713,7 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
5724
5713
  this.root.destroy();
5725
5714
  this.scheduler.processTasks();
5726
5715
  }
5727
- window.__OWL_DEVTOOLS__.apps.delete(this);
5716
+ apps.delete(this);
5728
5717
  }
5729
5718
  createComponent(name, isStatic, hasSlotsProp, hasDynamicPropList, propList) {
5730
5719
  const isDynamic = !isStatic;
@@ -5799,6 +5788,7 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
5799
5788
  }
5800
5789
  }
5801
5790
  App.validateTarget = validateTarget;
5791
+ App.apps = apps;
5802
5792
  App.version = version;
5803
5793
  async function mount(C, target, config = {}) {
5804
5794
  return new App(C, config).mount(target, config);
@@ -6033,8 +6023,8 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
6033
6023
  Object.defineProperty(exports, '__esModule', { value: true });
6034
6024
 
6035
6025
 
6036
- __info__.date = '2023-08-02T06:20:03.634Z';
6037
- __info__.hash = '8f9ad98';
6026
+ __info__.date = '2023-09-25T11:48:01.531Z';
6027
+ __info__.hash = '752160f';
6038
6028
  __info__.url = 'https://github.com/odoo/owl';
6039
6029
 
6040
6030