@odoo/owl 2.0.0-beta-21 → 2.0.0-beta-22

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.cjs.js CHANGED
@@ -2907,14 +2907,15 @@ function shallowEqual(l1, l2) {
2907
2907
  return true;
2908
2908
  }
2909
2909
  class LazyValue {
2910
- constructor(fn, ctx, component, node) {
2910
+ constructor(fn, ctx, component, node, key) {
2911
2911
  this.fn = fn;
2912
2912
  this.ctx = capture(ctx);
2913
2913
  this.component = component;
2914
2914
  this.node = node;
2915
+ this.key = key;
2915
2916
  }
2916
2917
  evaluate() {
2917
- return this.fn.call(this.component, this.ctx, this.node);
2918
+ return this.fn.call(this.component, this.ctx, this.node, this.key);
2918
2919
  }
2919
2920
  toString() {
2920
2921
  return this.evaluate().toString();
@@ -3600,6 +3601,13 @@ class CodeTarget {
3600
3601
  result.push(`}`);
3601
3602
  return result.join("\n ");
3602
3603
  }
3604
+ currentKey(ctx) {
3605
+ let key = this.loopLevel ? `key${this.loopLevel}` : "key";
3606
+ if (ctx.tKeyExpr) {
3607
+ key = `${ctx.tKeyExpr} + ${key}`;
3608
+ }
3609
+ return key;
3610
+ }
3603
3611
  }
3604
3612
  const TRANSLATABLE_ATTRS = ["label", "title", "placeholder", "alt"];
3605
3613
  const translationRE = /^(\s*)([\s\S]+?)(\s*)$/;
@@ -3729,18 +3737,14 @@ class CodeGenerator {
3729
3737
  }
3730
3738
  insertBlock(expression, block, ctx) {
3731
3739
  let blockExpr = block.generateExpr(expression);
3732
- const tKeyExpr = ctx.tKeyExpr;
3733
3740
  if (block.parentVar) {
3734
- let keyArg = `key${this.target.loopLevel}`;
3735
- if (tKeyExpr) {
3736
- keyArg = `${tKeyExpr} + ${keyArg}`;
3737
- }
3741
+ let key = this.target.currentKey(ctx);
3738
3742
  this.helpers.add("withKey");
3739
- this.addLine(`${block.parentVar}[${ctx.index}] = withKey(${blockExpr}, ${keyArg});`);
3743
+ this.addLine(`${block.parentVar}[${ctx.index}] = withKey(${blockExpr}, ${key});`);
3740
3744
  return;
3741
3745
  }
3742
- if (tKeyExpr) {
3743
- blockExpr = `toggler(${tKeyExpr}, ${blockExpr})`;
3746
+ if (ctx.tKeyExpr) {
3747
+ blockExpr = `toggler(${ctx.tKeyExpr}, ${blockExpr})`;
3744
3748
  }
3745
3749
  if (block.isRoot && !ctx.preventRoot) {
3746
3750
  if (this.target.on) {
@@ -3785,74 +3789,62 @@ class CodeGenerator {
3785
3789
  })
3786
3790
  .join("");
3787
3791
  }
3792
+ /**
3793
+ * @returns the newly created block name, if any
3794
+ */
3788
3795
  compileAST(ast, ctx) {
3789
3796
  switch (ast.type) {
3790
3797
  case 1 /* Comment */:
3791
- this.compileComment(ast, ctx);
3792
- break;
3798
+ return this.compileComment(ast, ctx);
3793
3799
  case 0 /* Text */:
3794
- this.compileText(ast, ctx);
3795
- break;
3800
+ return this.compileText(ast, ctx);
3796
3801
  case 2 /* DomNode */:
3797
- this.compileTDomNode(ast, ctx);
3798
- break;
3802
+ return this.compileTDomNode(ast, ctx);
3799
3803
  case 4 /* TEsc */:
3800
- this.compileTEsc(ast, ctx);
3801
- break;
3804
+ return this.compileTEsc(ast, ctx);
3802
3805
  case 8 /* TOut */:
3803
- this.compileTOut(ast, ctx);
3804
- break;
3806
+ return this.compileTOut(ast, ctx);
3805
3807
  case 5 /* TIf */:
3806
- this.compileTIf(ast, ctx);
3807
- break;
3808
+ return this.compileTIf(ast, ctx);
3808
3809
  case 9 /* TForEach */:
3809
- this.compileTForeach(ast, ctx);
3810
- break;
3810
+ return this.compileTForeach(ast, ctx);
3811
3811
  case 10 /* TKey */:
3812
- this.compileTKey(ast, ctx);
3813
- break;
3812
+ return this.compileTKey(ast, ctx);
3814
3813
  case 3 /* Multi */:
3815
- this.compileMulti(ast, ctx);
3816
- break;
3814
+ return this.compileMulti(ast, ctx);
3817
3815
  case 7 /* TCall */:
3818
- this.compileTCall(ast, ctx);
3819
- break;
3816
+ return this.compileTCall(ast, ctx);
3820
3817
  case 15 /* TCallBlock */:
3821
- this.compileTCallBlock(ast, ctx);
3822
- break;
3818
+ return this.compileTCallBlock(ast, ctx);
3823
3819
  case 6 /* TSet */:
3824
- this.compileTSet(ast, ctx);
3825
- break;
3820
+ return this.compileTSet(ast, ctx);
3826
3821
  case 11 /* TComponent */:
3827
- this.compileComponent(ast, ctx);
3828
- break;
3822
+ return this.compileComponent(ast, ctx);
3829
3823
  case 12 /* TDebug */:
3830
- this.compileDebug(ast, ctx);
3831
- break;
3824
+ return this.compileDebug(ast, ctx);
3832
3825
  case 13 /* TLog */:
3833
- this.compileLog(ast, ctx);
3834
- break;
3826
+ return this.compileLog(ast, ctx);
3835
3827
  case 14 /* TSlot */:
3836
- this.compileTSlot(ast, ctx);
3837
- break;
3828
+ return this.compileTSlot(ast, ctx);
3838
3829
  case 16 /* TTranslation */:
3839
- this.compileTTranslation(ast, ctx);
3840
- break;
3830
+ return this.compileTTranslation(ast, ctx);
3841
3831
  case 17 /* TPortal */:
3842
- this.compileTPortal(ast, ctx);
3832
+ return this.compileTPortal(ast, ctx);
3843
3833
  }
3844
3834
  }
3845
3835
  compileDebug(ast, ctx) {
3846
3836
  this.addLine(`debugger;`);
3847
3837
  if (ast.content) {
3848
- this.compileAST(ast.content, ctx);
3838
+ return this.compileAST(ast.content, ctx);
3849
3839
  }
3840
+ return null;
3850
3841
  }
3851
3842
  compileLog(ast, ctx) {
3852
3843
  this.addLine(`console.log(${compileExpr(ast.expr)});`);
3853
3844
  if (ast.content) {
3854
- this.compileAST(ast.content, ctx);
3845
+ return this.compileAST(ast.content, ctx);
3855
3846
  }
3847
+ return null;
3856
3848
  }
3857
3849
  compileComment(ast, ctx) {
3858
3850
  let { block, forceNewBlock } = ctx;
@@ -3868,6 +3860,7 @@ class CodeGenerator {
3868
3860
  const text = xmlDoc.createComment(ast.value);
3869
3861
  block.insert(text);
3870
3862
  }
3863
+ return block.varName;
3871
3864
  }
3872
3865
  compileText(ast, ctx) {
3873
3866
  let { block, forceNewBlock } = ctx;
@@ -3887,6 +3880,7 @@ class CodeGenerator {
3887
3880
  const createFn = ast.type === 0 /* Text */ ? xmlDoc.createTextNode : xmlDoc.createComment;
3888
3881
  block.insert(createFn.call(xmlDoc, value));
3889
3882
  }
3883
+ return block.varName;
3890
3884
  }
3891
3885
  generateHandlerCode(rawEvent, handler) {
3892
3886
  const modifiers = rawEvent
@@ -4079,6 +4073,7 @@ class CodeGenerator {
4079
4073
  this.addLine(`let ${block.children.map((c) => c.varName)};`, codeIdx);
4080
4074
  }
4081
4075
  }
4076
+ return block.varName;
4082
4077
  }
4083
4078
  compileTEsc(ast, ctx) {
4084
4079
  let { block, forceNewBlock } = ctx;
@@ -4103,6 +4098,7 @@ class CodeGenerator {
4103
4098
  const text = xmlDoc.createElement(`block-text-${idx}`);
4104
4099
  block.insert(text);
4105
4100
  }
4101
+ return block.varName;
4106
4102
  }
4107
4103
  compileTOut(ast, ctx) {
4108
4104
  let { block } = ctx;
@@ -4128,6 +4124,7 @@ class CodeGenerator {
4128
4124
  blockStr = `safeOutput(${compileExpr(ast.expr)})`;
4129
4125
  }
4130
4126
  this.insertBlock(blockStr, block, ctx);
4127
+ return block.varName;
4131
4128
  }
4132
4129
  compileTIfBranch(content, block, ctx) {
4133
4130
  this.target.indentLevel++;
@@ -4182,6 +4179,7 @@ class CodeGenerator {
4182
4179
  const args = block.children.map((c) => c.varName).join(", ");
4183
4180
  this.insertBlock(`multi([${args}])`, block, ctx);
4184
4181
  }
4182
+ return block.varName;
4185
4183
  }
4186
4184
  compileTForeach(ast, ctx) {
4187
4185
  let { block } = ctx;
@@ -4254,6 +4252,7 @@ class CodeGenerator {
4254
4252
  this.addLine(`ctx = ctx.__proto__;`);
4255
4253
  }
4256
4254
  this.insertBlock("l", block, ctx);
4255
+ return block.varName;
4257
4256
  }
4258
4257
  compileTKey(ast, ctx) {
4259
4258
  const tKeyExpr = generateId("tKey_");
@@ -4263,7 +4262,7 @@ class CodeGenerator {
4263
4262
  block: ctx.block,
4264
4263
  index: ctx.index,
4265
4264
  });
4266
- this.compileAST(ast.content, ctx);
4265
+ return this.compileAST(ast.content, ctx);
4267
4266
  }
4268
4267
  compileMulti(ast, ctx) {
4269
4268
  let { block, forceNewBlock } = ctx;
@@ -4271,11 +4270,13 @@ class CodeGenerator {
4271
4270
  let codeIdx = this.target.code.length;
4272
4271
  if (isNewBlock) {
4273
4272
  const n = ast.content.filter((c) => c.type !== 6 /* TSet */).length;
4273
+ let result = null;
4274
4274
  if (n <= 1) {
4275
4275
  for (let child of ast.content) {
4276
- this.compileAST(child, ctx);
4276
+ const blockName = this.compileAST(child, ctx);
4277
+ result = result || blockName;
4277
4278
  }
4278
- return;
4279
+ return result;
4279
4280
  }
4280
4281
  block = this.createBlock(block, "multi", ctx);
4281
4282
  }
@@ -4315,6 +4316,7 @@ class CodeGenerator {
4315
4316
  const args = block.children.map((c) => c.varName).join(", ");
4316
4317
  this.insertBlock(`multi([${args}])`, block, ctx);
4317
4318
  }
4319
+ return block.varName;
4318
4320
  }
4319
4321
  compileTCall(ast, ctx) {
4320
4322
  let { block, forceNewBlock } = ctx;
@@ -4327,12 +4329,11 @@ class CodeGenerator {
4327
4329
  this.addLine(`${ctxVar} = Object.create(${ctxVar});`);
4328
4330
  this.addLine(`${ctxVar}[isBoundary] = 1;`);
4329
4331
  this.helpers.add("isBoundary");
4330
- const nextId = BlockDescription.nextBlockId;
4331
4332
  const subCtx = createContext(ctx, { preventRoot: true, ctxVar });
4332
- this.compileAST({ type: 3 /* Multi */, content: ast.body }, subCtx);
4333
- if (nextId !== BlockDescription.nextBlockId) {
4333
+ const bl = this.compileMulti({ type: 3 /* Multi */, content: ast.body }, subCtx);
4334
+ if (bl) {
4334
4335
  this.helpers.add("zero");
4335
- this.addLine(`${ctxVar}[zero] = b${nextId};`);
4336
+ this.addLine(`${ctxVar}[zero] = ${bl};`);
4336
4337
  }
4337
4338
  }
4338
4339
  const isDynamic = INTERP_REGEXP.test(ast.name);
@@ -4367,6 +4368,7 @@ class CodeGenerator {
4367
4368
  if (ast.body && !ctx.isLast) {
4368
4369
  this.addLine(`${ctxVar} = ${ctxVar}.__proto__;`);
4369
4370
  }
4371
+ return block.varName;
4370
4372
  }
4371
4373
  compileTCallBlock(ast, ctx) {
4372
4374
  let { block, forceNewBlock } = ctx;
@@ -4377,6 +4379,7 @@ class CodeGenerator {
4377
4379
  }
4378
4380
  block = this.createBlock(block, "multi", ctx);
4379
4381
  this.insertBlock(compileExpr(ast.name), block, { ...ctx, forceNewBlock: !block });
4382
+ return block.varName;
4380
4383
  }
4381
4384
  compileTSet(ast, ctx) {
4382
4385
  this.target.shouldProtectScope = true;
@@ -4386,7 +4389,8 @@ class CodeGenerator {
4386
4389
  this.helpers.add("LazyValue");
4387
4390
  const bodyAst = { type: 3 /* Multi */, content: ast.body };
4388
4391
  const name = this.compileInNewTarget("value", bodyAst, ctx);
4389
- let value = `new LazyValue(${name}, ctx, this, node)`;
4392
+ let key = this.target.currentKey(ctx);
4393
+ let value = `new LazyValue(${name}, ctx, this, node, ${key})`;
4390
4394
  value = ast.value ? (value ? `withDefault(${expr}, ${value})` : expr) : value;
4391
4395
  this.addLine(`ctx[\`${ast.name}\`] = ${value};`);
4392
4396
  }
@@ -4406,6 +4410,7 @@ class CodeGenerator {
4406
4410
  this.helpers.add("setContextValue");
4407
4411
  this.addLine(`setContextValue(${ctx.ctxVar || "ctx"}, "${ast.name}", ${value});`);
4408
4412
  }
4413
+ return null;
4409
4414
  }
4410
4415
  generateComponentKey() {
4411
4416
  const parts = [generateId("__")];
@@ -4536,6 +4541,7 @@ class CodeGenerator {
4536
4541
  }
4537
4542
  block = this.createBlock(block, "multi", ctx);
4538
4543
  this.insertBlock(blockExpr, block, ctx);
4544
+ return block.varName;
4539
4545
  }
4540
4546
  wrapWithEventCatcher(expr, on) {
4541
4547
  this.helpers.add("createCatcher");
@@ -4602,11 +4608,13 @@ class CodeGenerator {
4602
4608
  }
4603
4609
  block = this.createBlock(block, "multi", ctx);
4604
4610
  this.insertBlock(blockString, block, { ...ctx, forceNewBlock: false });
4611
+ return block.varName;
4605
4612
  }
4606
4613
  compileTTranslation(ast, ctx) {
4607
4614
  if (ast.content) {
4608
- this.compileAST(ast.content, Object.assign({}, ctx, { translate: false }));
4615
+ return this.compileAST(ast.content, Object.assign({}, ctx, { translate: false }));
4609
4616
  }
4617
+ return null;
4610
4618
  }
4611
4619
  compileTPortal(ast, ctx) {
4612
4620
  if (!this.staticDefs.find((d) => d.id === "Portal")) {
@@ -4633,6 +4641,7 @@ class CodeGenerator {
4633
4641
  }
4634
4642
  block = this.createBlock(block, "multi", ctx);
4635
4643
  this.insertBlock(blockString, block, { ...ctx, forceNewBlock: false });
4644
+ return block.varName;
4636
4645
  }
4637
4646
  }
4638
4647
 
@@ -5800,7 +5809,7 @@ exports.whenReady = whenReady;
5800
5809
  exports.xml = xml;
5801
5810
 
5802
5811
 
5803
- __info__.version = '2.0.0-beta-21';
5804
- __info__.date = '2022-09-26T13:44:22.515Z';
5805
- __info__.hash = 'ab72cdd';
5812
+ __info__.version = '2.0.0-beta-22';
5813
+ __info__.date = '2022-09-29T07:17:18.044Z';
5814
+ __info__.hash = '64bad25';
5806
5815
  __info__.url = 'https://github.com/odoo/owl';
package/dist/owl.es.js CHANGED
@@ -2903,14 +2903,15 @@ function shallowEqual(l1, l2) {
2903
2903
  return true;
2904
2904
  }
2905
2905
  class LazyValue {
2906
- constructor(fn, ctx, component, node) {
2906
+ constructor(fn, ctx, component, node, key) {
2907
2907
  this.fn = fn;
2908
2908
  this.ctx = capture(ctx);
2909
2909
  this.component = component;
2910
2910
  this.node = node;
2911
+ this.key = key;
2911
2912
  }
2912
2913
  evaluate() {
2913
- return this.fn.call(this.component, this.ctx, this.node);
2914
+ return this.fn.call(this.component, this.ctx, this.node, this.key);
2914
2915
  }
2915
2916
  toString() {
2916
2917
  return this.evaluate().toString();
@@ -3596,6 +3597,13 @@ class CodeTarget {
3596
3597
  result.push(`}`);
3597
3598
  return result.join("\n ");
3598
3599
  }
3600
+ currentKey(ctx) {
3601
+ let key = this.loopLevel ? `key${this.loopLevel}` : "key";
3602
+ if (ctx.tKeyExpr) {
3603
+ key = `${ctx.tKeyExpr} + ${key}`;
3604
+ }
3605
+ return key;
3606
+ }
3599
3607
  }
3600
3608
  const TRANSLATABLE_ATTRS = ["label", "title", "placeholder", "alt"];
3601
3609
  const translationRE = /^(\s*)([\s\S]+?)(\s*)$/;
@@ -3725,18 +3733,14 @@ class CodeGenerator {
3725
3733
  }
3726
3734
  insertBlock(expression, block, ctx) {
3727
3735
  let blockExpr = block.generateExpr(expression);
3728
- const tKeyExpr = ctx.tKeyExpr;
3729
3736
  if (block.parentVar) {
3730
- let keyArg = `key${this.target.loopLevel}`;
3731
- if (tKeyExpr) {
3732
- keyArg = `${tKeyExpr} + ${keyArg}`;
3733
- }
3737
+ let key = this.target.currentKey(ctx);
3734
3738
  this.helpers.add("withKey");
3735
- this.addLine(`${block.parentVar}[${ctx.index}] = withKey(${blockExpr}, ${keyArg});`);
3739
+ this.addLine(`${block.parentVar}[${ctx.index}] = withKey(${blockExpr}, ${key});`);
3736
3740
  return;
3737
3741
  }
3738
- if (tKeyExpr) {
3739
- blockExpr = `toggler(${tKeyExpr}, ${blockExpr})`;
3742
+ if (ctx.tKeyExpr) {
3743
+ blockExpr = `toggler(${ctx.tKeyExpr}, ${blockExpr})`;
3740
3744
  }
3741
3745
  if (block.isRoot && !ctx.preventRoot) {
3742
3746
  if (this.target.on) {
@@ -3781,74 +3785,62 @@ class CodeGenerator {
3781
3785
  })
3782
3786
  .join("");
3783
3787
  }
3788
+ /**
3789
+ * @returns the newly created block name, if any
3790
+ */
3784
3791
  compileAST(ast, ctx) {
3785
3792
  switch (ast.type) {
3786
3793
  case 1 /* Comment */:
3787
- this.compileComment(ast, ctx);
3788
- break;
3794
+ return this.compileComment(ast, ctx);
3789
3795
  case 0 /* Text */:
3790
- this.compileText(ast, ctx);
3791
- break;
3796
+ return this.compileText(ast, ctx);
3792
3797
  case 2 /* DomNode */:
3793
- this.compileTDomNode(ast, ctx);
3794
- break;
3798
+ return this.compileTDomNode(ast, ctx);
3795
3799
  case 4 /* TEsc */:
3796
- this.compileTEsc(ast, ctx);
3797
- break;
3800
+ return this.compileTEsc(ast, ctx);
3798
3801
  case 8 /* TOut */:
3799
- this.compileTOut(ast, ctx);
3800
- break;
3802
+ return this.compileTOut(ast, ctx);
3801
3803
  case 5 /* TIf */:
3802
- this.compileTIf(ast, ctx);
3803
- break;
3804
+ return this.compileTIf(ast, ctx);
3804
3805
  case 9 /* TForEach */:
3805
- this.compileTForeach(ast, ctx);
3806
- break;
3806
+ return this.compileTForeach(ast, ctx);
3807
3807
  case 10 /* TKey */:
3808
- this.compileTKey(ast, ctx);
3809
- break;
3808
+ return this.compileTKey(ast, ctx);
3810
3809
  case 3 /* Multi */:
3811
- this.compileMulti(ast, ctx);
3812
- break;
3810
+ return this.compileMulti(ast, ctx);
3813
3811
  case 7 /* TCall */:
3814
- this.compileTCall(ast, ctx);
3815
- break;
3812
+ return this.compileTCall(ast, ctx);
3816
3813
  case 15 /* TCallBlock */:
3817
- this.compileTCallBlock(ast, ctx);
3818
- break;
3814
+ return this.compileTCallBlock(ast, ctx);
3819
3815
  case 6 /* TSet */:
3820
- this.compileTSet(ast, ctx);
3821
- break;
3816
+ return this.compileTSet(ast, ctx);
3822
3817
  case 11 /* TComponent */:
3823
- this.compileComponent(ast, ctx);
3824
- break;
3818
+ return this.compileComponent(ast, ctx);
3825
3819
  case 12 /* TDebug */:
3826
- this.compileDebug(ast, ctx);
3827
- break;
3820
+ return this.compileDebug(ast, ctx);
3828
3821
  case 13 /* TLog */:
3829
- this.compileLog(ast, ctx);
3830
- break;
3822
+ return this.compileLog(ast, ctx);
3831
3823
  case 14 /* TSlot */:
3832
- this.compileTSlot(ast, ctx);
3833
- break;
3824
+ return this.compileTSlot(ast, ctx);
3834
3825
  case 16 /* TTranslation */:
3835
- this.compileTTranslation(ast, ctx);
3836
- break;
3826
+ return this.compileTTranslation(ast, ctx);
3837
3827
  case 17 /* TPortal */:
3838
- this.compileTPortal(ast, ctx);
3828
+ return this.compileTPortal(ast, ctx);
3839
3829
  }
3840
3830
  }
3841
3831
  compileDebug(ast, ctx) {
3842
3832
  this.addLine(`debugger;`);
3843
3833
  if (ast.content) {
3844
- this.compileAST(ast.content, ctx);
3834
+ return this.compileAST(ast.content, ctx);
3845
3835
  }
3836
+ return null;
3846
3837
  }
3847
3838
  compileLog(ast, ctx) {
3848
3839
  this.addLine(`console.log(${compileExpr(ast.expr)});`);
3849
3840
  if (ast.content) {
3850
- this.compileAST(ast.content, ctx);
3841
+ return this.compileAST(ast.content, ctx);
3851
3842
  }
3843
+ return null;
3852
3844
  }
3853
3845
  compileComment(ast, ctx) {
3854
3846
  let { block, forceNewBlock } = ctx;
@@ -3864,6 +3856,7 @@ class CodeGenerator {
3864
3856
  const text = xmlDoc.createComment(ast.value);
3865
3857
  block.insert(text);
3866
3858
  }
3859
+ return block.varName;
3867
3860
  }
3868
3861
  compileText(ast, ctx) {
3869
3862
  let { block, forceNewBlock } = ctx;
@@ -3883,6 +3876,7 @@ class CodeGenerator {
3883
3876
  const createFn = ast.type === 0 /* Text */ ? xmlDoc.createTextNode : xmlDoc.createComment;
3884
3877
  block.insert(createFn.call(xmlDoc, value));
3885
3878
  }
3879
+ return block.varName;
3886
3880
  }
3887
3881
  generateHandlerCode(rawEvent, handler) {
3888
3882
  const modifiers = rawEvent
@@ -4075,6 +4069,7 @@ class CodeGenerator {
4075
4069
  this.addLine(`let ${block.children.map((c) => c.varName)};`, codeIdx);
4076
4070
  }
4077
4071
  }
4072
+ return block.varName;
4078
4073
  }
4079
4074
  compileTEsc(ast, ctx) {
4080
4075
  let { block, forceNewBlock } = ctx;
@@ -4099,6 +4094,7 @@ class CodeGenerator {
4099
4094
  const text = xmlDoc.createElement(`block-text-${idx}`);
4100
4095
  block.insert(text);
4101
4096
  }
4097
+ return block.varName;
4102
4098
  }
4103
4099
  compileTOut(ast, ctx) {
4104
4100
  let { block } = ctx;
@@ -4124,6 +4120,7 @@ class CodeGenerator {
4124
4120
  blockStr = `safeOutput(${compileExpr(ast.expr)})`;
4125
4121
  }
4126
4122
  this.insertBlock(blockStr, block, ctx);
4123
+ return block.varName;
4127
4124
  }
4128
4125
  compileTIfBranch(content, block, ctx) {
4129
4126
  this.target.indentLevel++;
@@ -4178,6 +4175,7 @@ class CodeGenerator {
4178
4175
  const args = block.children.map((c) => c.varName).join(", ");
4179
4176
  this.insertBlock(`multi([${args}])`, block, ctx);
4180
4177
  }
4178
+ return block.varName;
4181
4179
  }
4182
4180
  compileTForeach(ast, ctx) {
4183
4181
  let { block } = ctx;
@@ -4250,6 +4248,7 @@ class CodeGenerator {
4250
4248
  this.addLine(`ctx = ctx.__proto__;`);
4251
4249
  }
4252
4250
  this.insertBlock("l", block, ctx);
4251
+ return block.varName;
4253
4252
  }
4254
4253
  compileTKey(ast, ctx) {
4255
4254
  const tKeyExpr = generateId("tKey_");
@@ -4259,7 +4258,7 @@ class CodeGenerator {
4259
4258
  block: ctx.block,
4260
4259
  index: ctx.index,
4261
4260
  });
4262
- this.compileAST(ast.content, ctx);
4261
+ return this.compileAST(ast.content, ctx);
4263
4262
  }
4264
4263
  compileMulti(ast, ctx) {
4265
4264
  let { block, forceNewBlock } = ctx;
@@ -4267,11 +4266,13 @@ class CodeGenerator {
4267
4266
  let codeIdx = this.target.code.length;
4268
4267
  if (isNewBlock) {
4269
4268
  const n = ast.content.filter((c) => c.type !== 6 /* TSet */).length;
4269
+ let result = null;
4270
4270
  if (n <= 1) {
4271
4271
  for (let child of ast.content) {
4272
- this.compileAST(child, ctx);
4272
+ const blockName = this.compileAST(child, ctx);
4273
+ result = result || blockName;
4273
4274
  }
4274
- return;
4275
+ return result;
4275
4276
  }
4276
4277
  block = this.createBlock(block, "multi", ctx);
4277
4278
  }
@@ -4311,6 +4312,7 @@ class CodeGenerator {
4311
4312
  const args = block.children.map((c) => c.varName).join(", ");
4312
4313
  this.insertBlock(`multi([${args}])`, block, ctx);
4313
4314
  }
4315
+ return block.varName;
4314
4316
  }
4315
4317
  compileTCall(ast, ctx) {
4316
4318
  let { block, forceNewBlock } = ctx;
@@ -4323,12 +4325,11 @@ class CodeGenerator {
4323
4325
  this.addLine(`${ctxVar} = Object.create(${ctxVar});`);
4324
4326
  this.addLine(`${ctxVar}[isBoundary] = 1;`);
4325
4327
  this.helpers.add("isBoundary");
4326
- const nextId = BlockDescription.nextBlockId;
4327
4328
  const subCtx = createContext(ctx, { preventRoot: true, ctxVar });
4328
- this.compileAST({ type: 3 /* Multi */, content: ast.body }, subCtx);
4329
- if (nextId !== BlockDescription.nextBlockId) {
4329
+ const bl = this.compileMulti({ type: 3 /* Multi */, content: ast.body }, subCtx);
4330
+ if (bl) {
4330
4331
  this.helpers.add("zero");
4331
- this.addLine(`${ctxVar}[zero] = b${nextId};`);
4332
+ this.addLine(`${ctxVar}[zero] = ${bl};`);
4332
4333
  }
4333
4334
  }
4334
4335
  const isDynamic = INTERP_REGEXP.test(ast.name);
@@ -4363,6 +4364,7 @@ class CodeGenerator {
4363
4364
  if (ast.body && !ctx.isLast) {
4364
4365
  this.addLine(`${ctxVar} = ${ctxVar}.__proto__;`);
4365
4366
  }
4367
+ return block.varName;
4366
4368
  }
4367
4369
  compileTCallBlock(ast, ctx) {
4368
4370
  let { block, forceNewBlock } = ctx;
@@ -4373,6 +4375,7 @@ class CodeGenerator {
4373
4375
  }
4374
4376
  block = this.createBlock(block, "multi", ctx);
4375
4377
  this.insertBlock(compileExpr(ast.name), block, { ...ctx, forceNewBlock: !block });
4378
+ return block.varName;
4376
4379
  }
4377
4380
  compileTSet(ast, ctx) {
4378
4381
  this.target.shouldProtectScope = true;
@@ -4382,7 +4385,8 @@ class CodeGenerator {
4382
4385
  this.helpers.add("LazyValue");
4383
4386
  const bodyAst = { type: 3 /* Multi */, content: ast.body };
4384
4387
  const name = this.compileInNewTarget("value", bodyAst, ctx);
4385
- let value = `new LazyValue(${name}, ctx, this, node)`;
4388
+ let key = this.target.currentKey(ctx);
4389
+ let value = `new LazyValue(${name}, ctx, this, node, ${key})`;
4386
4390
  value = ast.value ? (value ? `withDefault(${expr}, ${value})` : expr) : value;
4387
4391
  this.addLine(`ctx[\`${ast.name}\`] = ${value};`);
4388
4392
  }
@@ -4402,6 +4406,7 @@ class CodeGenerator {
4402
4406
  this.helpers.add("setContextValue");
4403
4407
  this.addLine(`setContextValue(${ctx.ctxVar || "ctx"}, "${ast.name}", ${value});`);
4404
4408
  }
4409
+ return null;
4405
4410
  }
4406
4411
  generateComponentKey() {
4407
4412
  const parts = [generateId("__")];
@@ -4532,6 +4537,7 @@ class CodeGenerator {
4532
4537
  }
4533
4538
  block = this.createBlock(block, "multi", ctx);
4534
4539
  this.insertBlock(blockExpr, block, ctx);
4540
+ return block.varName;
4535
4541
  }
4536
4542
  wrapWithEventCatcher(expr, on) {
4537
4543
  this.helpers.add("createCatcher");
@@ -4598,11 +4604,13 @@ class CodeGenerator {
4598
4604
  }
4599
4605
  block = this.createBlock(block, "multi", ctx);
4600
4606
  this.insertBlock(blockString, block, { ...ctx, forceNewBlock: false });
4607
+ return block.varName;
4601
4608
  }
4602
4609
  compileTTranslation(ast, ctx) {
4603
4610
  if (ast.content) {
4604
- this.compileAST(ast.content, Object.assign({}, ctx, { translate: false }));
4611
+ return this.compileAST(ast.content, Object.assign({}, ctx, { translate: false }));
4605
4612
  }
4613
+ return null;
4606
4614
  }
4607
4615
  compileTPortal(ast, ctx) {
4608
4616
  if (!this.staticDefs.find((d) => d.id === "Portal")) {
@@ -4629,6 +4637,7 @@ class CodeGenerator {
4629
4637
  }
4630
4638
  block = this.createBlock(block, "multi", ctx);
4631
4639
  this.insertBlock(blockString, block, { ...ctx, forceNewBlock: false });
4640
+ return block.varName;
4632
4641
  }
4633
4642
  }
4634
4643
 
@@ -5763,7 +5772,7 @@ TemplateSet.prototype._compileTemplate = function _compileTemplate(name, templat
5763
5772
  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, whenReady, xml };
5764
5773
 
5765
5774
 
5766
- __info__.version = '2.0.0-beta-21';
5767
- __info__.date = '2022-09-26T13:44:22.515Z';
5768
- __info__.hash = 'ab72cdd';
5775
+ __info__.version = '2.0.0-beta-22';
5776
+ __info__.date = '2022-09-29T07:17:18.044Z';
5777
+ __info__.hash = '64bad25';
5769
5778
  __info__.url = 'https://github.com/odoo/owl';