@odoo/owl 2.0.0 → 2.0.2

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
@@ -41,8 +41,11 @@
41
41
  this.parentEl = parent;
42
42
  this.child.mount(parent, afterNode);
43
43
  }
44
- moveBefore(other, afterNode) {
45
- this.child.moveBefore(other ? other.child : null, afterNode);
44
+ moveBeforeDOMNode(node, parent) {
45
+ this.child.moveBeforeDOMNode(node, parent);
46
+ }
47
+ moveBeforeVNode(other, afterNode) {
48
+ this.moveBeforeDOMNode((other && other.firstNode()) || afterNode);
46
49
  }
47
50
  patch(other, withBeforeRemove) {
48
51
  if (this === other) {
@@ -418,7 +421,22 @@
418
421
  this.anchors = anchors;
419
422
  this.parentEl = parent;
420
423
  }
421
- moveBefore(other, afterNode) {
424
+ moveBeforeDOMNode(node, parent = this.parentEl) {
425
+ this.parentEl = parent;
426
+ const children = this.children;
427
+ const anchors = this.anchors;
428
+ for (let i = 0, l = children.length; i < l; i++) {
429
+ let child = children[i];
430
+ if (child) {
431
+ child.moveBeforeDOMNode(node, parent);
432
+ }
433
+ else {
434
+ const anchor = anchors[i];
435
+ nodeInsertBefore$3.call(parent, anchor, node);
436
+ }
437
+ }
438
+ }
439
+ moveBeforeVNode(other, afterNode) {
422
440
  if (other) {
423
441
  const next = other.children[0];
424
442
  afterNode = (next ? next.firstNode() : other.anchors[0]) || null;
@@ -429,7 +447,7 @@
429
447
  for (let i = 0, l = children.length; i < l; i++) {
430
448
  let child = children[i];
431
449
  if (child) {
432
- child.moveBefore(null, afterNode);
450
+ child.moveBeforeVNode(null, afterNode);
433
451
  }
434
452
  else {
435
453
  const anchor = anchors[i];
@@ -527,9 +545,12 @@
527
545
  nodeInsertBefore$2.call(parent, node, afterNode);
528
546
  this.el = node;
529
547
  }
530
- moveBefore(other, afterNode) {
531
- const target = other ? other.el : afterNode;
532
- nodeInsertBefore$2.call(this.parentEl, this.el, target);
548
+ moveBeforeDOMNode(node, parent = this.parentEl) {
549
+ this.parentEl = parent;
550
+ nodeInsertBefore$2.call(parent, this.el, node);
551
+ }
552
+ moveBeforeVNode(other, afterNode) {
553
+ nodeInsertBefore$2.call(this.parentEl, this.el, other ? other.el : afterNode);
533
554
  }
534
555
  beforeRemove() { }
535
556
  remove() {
@@ -971,9 +992,12 @@
971
992
  firstNode() {
972
993
  return this.el;
973
994
  }
974
- moveBefore(other, afterNode) {
975
- const target = other ? other.el : afterNode;
976
- nodeInsertBefore.call(this.parentEl, this.el, target);
995
+ moveBeforeDOMNode(node, parent = this.parentEl) {
996
+ this.parentEl = parent;
997
+ nodeInsertBefore.call(parent, this.el, node);
998
+ }
999
+ moveBeforeVNode(other, afterNode) {
1000
+ nodeInsertBefore.call(this.parentEl, this.el, other ? other.el : afterNode);
977
1001
  }
978
1002
  toString() {
979
1003
  const div = document.createElement("div");
@@ -1110,14 +1134,22 @@
1110
1134
  }
1111
1135
  this.parentEl = parent;
1112
1136
  }
1113
- moveBefore(other, afterNode) {
1137
+ moveBeforeDOMNode(node, parent = this.parentEl) {
1138
+ this.parentEl = parent;
1139
+ const children = this.children;
1140
+ for (let i = 0, l = children.length; i < l; i++) {
1141
+ children[i].moveBeforeDOMNode(node, parent);
1142
+ }
1143
+ parent.insertBefore(this.anchor, node);
1144
+ }
1145
+ moveBeforeVNode(other, afterNode) {
1114
1146
  if (other) {
1115
1147
  const next = other.children[0];
1116
1148
  afterNode = (next ? next.firstNode() : other.anchor) || null;
1117
1149
  }
1118
1150
  const children = this.children;
1119
1151
  for (let i = 0, l = children.length; i < l; i++) {
1120
- children[i].moveBefore(null, afterNode);
1152
+ children[i].moveBeforeVNode(null, afterNode);
1121
1153
  }
1122
1154
  this.parentEl.insertBefore(this.anchor, afterNode);
1123
1155
  }
@@ -1132,7 +1164,7 @@
1132
1164
  }
1133
1165
  this.children = ch2;
1134
1166
  const proto = ch2[0] || ch1[0];
1135
- const { mount: cMount, patch: cPatch, remove: cRemove, beforeRemove, moveBefore: cMoveBefore, firstNode: cFirstNode, } = proto;
1167
+ const { mount: cMount, patch: cPatch, remove: cRemove, beforeRemove, moveBeforeVNode: cMoveBefore, firstNode: cFirstNode, } = proto;
1136
1168
  const _anchor = this.anchor;
1137
1169
  const isOnlyChild = this.isOnlyChild;
1138
1170
  const parent = this.parentEl;
@@ -1314,13 +1346,16 @@
1314
1346
  nodeInsertBefore.call(parent, textNode, afterNode);
1315
1347
  }
1316
1348
  }
1317
- moveBefore(other, afterNode) {
1318
- const target = other ? other.content[0] : afterNode;
1319
- const parent = this.parentEl;
1349
+ moveBeforeDOMNode(node, parent = this.parentEl) {
1350
+ this.parentEl = parent;
1320
1351
  for (let elem of this.content) {
1321
- nodeInsertBefore.call(parent, elem, target);
1352
+ nodeInsertBefore.call(parent, elem, node);
1322
1353
  }
1323
1354
  }
1355
+ moveBeforeVNode(other, afterNode) {
1356
+ const target = other ? other.content[0] : afterNode;
1357
+ this.moveBeforeDOMNode(target);
1358
+ }
1324
1359
  patch(other) {
1325
1360
  if (this === other) {
1326
1361
  return;
@@ -1398,7 +1433,7 @@
1398
1433
  const target = ev.target;
1399
1434
  let currentNode = self.child.firstNode();
1400
1435
  const afterNode = self.afterNode;
1401
- while (currentNode !== afterNode) {
1436
+ while (currentNode && currentNode !== afterNode) {
1402
1437
  if (currentNode.contains(target)) {
1403
1438
  return origFn.call(this, ev);
1404
1439
  }
@@ -1407,8 +1442,17 @@
1407
1442
  };
1408
1443
  }
1409
1444
  }
1410
- moveBefore(other, afterNode) {
1411
- this.child.moveBefore(other ? other.child : null, afterNode);
1445
+ moveBeforeDOMNode(node, parent = this.parentEl) {
1446
+ this.parentEl = parent;
1447
+ this.child.moveBeforeDOMNode(node, parent);
1448
+ parent.insertBefore(this.afterNode, node);
1449
+ }
1450
+ moveBeforeVNode(other, afterNode) {
1451
+ if (other) {
1452
+ // check this with @ged-odoo for use in foreach
1453
+ afterNode = other.firstNode() || afterNode;
1454
+ }
1455
+ this.child.moveBeforeVNode(other ? other.child : null, afterNode);
1412
1456
  this.parentEl.insertBefore(this.afterNode, afterNode);
1413
1457
  }
1414
1458
  patch(other, withBeforeRemove) {
@@ -1699,10 +1743,6 @@
1699
1743
  }
1700
1744
  }
1701
1745
 
1702
- // Allows to get the target of a Reactive (used for making a new Reactive from the underlying object)
1703
- const TARGET = Symbol("Target");
1704
- // Escape hatch to prevent reactivity system to turn something into a reactive
1705
- const SKIP = Symbol("Skip");
1706
1746
  // Special key to subscribe to, to be notified of key creation/deletion
1707
1747
  const KEYCHANGES = Symbol("Key changes");
1708
1748
  const objectToString = Object.prototype.toString;
@@ -1743,6 +1783,7 @@
1743
1783
  function possiblyReactive(val, cb) {
1744
1784
  return canBeMadeReactive(val) ? reactive(val, cb) : val;
1745
1785
  }
1786
+ const skipped = new WeakSet();
1746
1787
  /**
1747
1788
  * Mark an object or array so that it is ignored by the reactivity system
1748
1789
  *
@@ -1750,7 +1791,7 @@
1750
1791
  * @returns the object itself
1751
1792
  */
1752
1793
  function markRaw(value) {
1753
- value[SKIP] = true;
1794
+ skipped.add(value);
1754
1795
  return value;
1755
1796
  }
1756
1797
  /**
@@ -1760,7 +1801,7 @@
1760
1801
  * @returns the underlying value
1761
1802
  */
1762
1803
  function toRaw(value) {
1763
- return value[TARGET] || value;
1804
+ return targets.has(value) ? targets.get(value) : value;
1764
1805
  }
1765
1806
  const targetToKeysToCallbacks = new WeakMap();
1766
1807
  /**
@@ -1842,6 +1883,8 @@
1842
1883
  };
1843
1884
  });
1844
1885
  }
1886
+ // Maps reactive objects to the underlying target
1887
+ const targets = new WeakMap();
1845
1888
  const reactiveCache = new WeakMap();
1846
1889
  /**
1847
1890
  * Creates a reactive proxy for an object. Reading data on the reactive object
@@ -1857,7 +1900,7 @@
1857
1900
  * Subscriptions:
1858
1901
  * + Reading a property on an object will subscribe you to changes in the value
1859
1902
  * of that property.
1860
- * + Accessing an object keys (eg with Object.keys or with `for..in`) will
1903
+ * + Accessing an object's keys (eg with Object.keys or with `for..in`) will
1861
1904
  * subscribe you to the creation/deletion of keys. Checking the presence of a
1862
1905
  * key on the object with 'in' has the same effect.
1863
1906
  * - getOwnPropertyDescriptor does not currently subscribe you to the property.
@@ -1874,12 +1917,12 @@
1874
1917
  if (!canBeMadeReactive(target)) {
1875
1918
  throw new OwlError(`Cannot make the given value reactive`);
1876
1919
  }
1877
- if (SKIP in target) {
1920
+ if (skipped.has(target)) {
1878
1921
  return target;
1879
1922
  }
1880
- const originalTarget = target[TARGET];
1881
- if (originalTarget) {
1882
- return reactive(originalTarget, callback);
1923
+ if (targets.has(target)) {
1924
+ // target is reactive, create a reactive on the underlying object instead
1925
+ return reactive(targets.get(target), callback);
1883
1926
  }
1884
1927
  if (!reactiveCache.has(target)) {
1885
1928
  reactiveCache.set(target, new WeakMap());
@@ -1892,6 +1935,7 @@
1892
1935
  : basicProxyHandler(callback);
1893
1936
  const proxy = new Proxy(target, handler);
1894
1937
  reactivesForTarget.set(callback, proxy);
1938
+ targets.set(proxy, target);
1895
1939
  }
1896
1940
  return reactivesForTarget.get(callback);
1897
1941
  }
@@ -1903,29 +1947,27 @@
1903
1947
  */
1904
1948
  function basicProxyHandler(callback) {
1905
1949
  return {
1906
- get(target, key, proxy) {
1907
- if (key === TARGET) {
1908
- return target;
1909
- }
1950
+ get(target, key, receiver) {
1910
1951
  // non-writable non-configurable properties cannot be made reactive
1911
1952
  const desc = Object.getOwnPropertyDescriptor(target, key);
1912
1953
  if (desc && !desc.writable && !desc.configurable) {
1913
- return Reflect.get(target, key, proxy);
1954
+ return Reflect.get(target, key, receiver);
1914
1955
  }
1915
1956
  observeTargetKey(target, key, callback);
1916
- return possiblyReactive(Reflect.get(target, key, proxy), callback);
1957
+ return possiblyReactive(Reflect.get(target, key, receiver), callback);
1917
1958
  },
1918
- set(target, key, value, proxy) {
1919
- const isNewKey = !objectHasOwnProperty.call(target, key);
1920
- const originalValue = Reflect.get(target, key, proxy);
1921
- const ret = Reflect.set(target, key, value, proxy);
1922
- if (isNewKey) {
1959
+ set(target, key, value, receiver) {
1960
+ const hadKey = objectHasOwnProperty.call(target, key);
1961
+ const originalValue = Reflect.get(target, key, receiver);
1962
+ const ret = Reflect.set(target, key, value, receiver);
1963
+ if (!hadKey && objectHasOwnProperty.call(target, key)) {
1923
1964
  notifyReactives(target, KEYCHANGES);
1924
1965
  }
1925
1966
  // While Array length may trigger the set trap, it's not actually set by this
1926
1967
  // method but is updated behind the scenes, and the trap is not called with the
1927
1968
  // new value. We disable the "same-value-optimization" for it because of that.
1928
- if (originalValue !== value || (Array.isArray(target) && key === "length")) {
1969
+ if (originalValue !== Reflect.get(target, key, receiver) ||
1970
+ (key === "length" && Array.isArray(target))) {
1929
1971
  notifyReactives(target, key);
1930
1972
  }
1931
1973
  return ret;
@@ -2101,10 +2143,8 @@
2101
2143
  // property is read.
2102
2144
  const specialHandlers = rawTypeToFuncHandlers[targetRawType](target, callback);
2103
2145
  return Object.assign(basicProxyHandler(callback), {
2146
+ // FIXME: probably broken when part of prototype chain since we ignore the receiver
2104
2147
  get(target, key) {
2105
- if (key === TARGET) {
2106
- return target;
2107
- }
2108
2148
  if (objectHasOwnProperty.call(specialHandlers, key)) {
2109
2149
  return specialHandlers[key];
2110
2150
  }
@@ -2264,7 +2304,7 @@
2264
2304
  this.childEnv = env;
2265
2305
  for (const key in props) {
2266
2306
  const prop = props[key];
2267
- if (prop && typeof prop === "object" && prop[TARGET]) {
2307
+ if (prop && typeof prop === "object" && targets.has(prop)) {
2268
2308
  props[key] = useState(prop);
2269
2309
  }
2270
2310
  }
@@ -2382,7 +2422,7 @@
2382
2422
  currentNode = this;
2383
2423
  for (const key in props) {
2384
2424
  const prop = props[key];
2385
- if (prop && typeof prop === "object" && prop[TARGET]) {
2425
+ if (prop && typeof prop === "object" && targets.has(prop)) {
2386
2426
  props[key] = useState(prop);
2387
2427
  }
2388
2428
  }
@@ -2444,8 +2484,11 @@
2444
2484
  this.children = this.fiber.childrenMap;
2445
2485
  this.fiber = null;
2446
2486
  }
2447
- moveBefore(other, afterNode) {
2448
- this.bdom.moveBefore(other ? other.bdom : null, afterNode);
2487
+ moveBeforeDOMNode(node, parent) {
2488
+ this.bdom.moveBeforeDOMNode(node, parent);
2489
+ }
2490
+ moveBeforeVNode(other, afterNode) {
2491
+ this.bdom.moveBeforeVNode(other ? other.bdom : null, afterNode);
2449
2492
  }
2450
2493
  patch() {
2451
2494
  if (this.fiber && this.fiber.parent) {
@@ -2662,7 +2705,7 @@
2662
2705
  if (!portal.target) {
2663
2706
  const target = document.querySelector(this.props.target);
2664
2707
  if (target) {
2665
- portal.content.moveBefore(target, null);
2708
+ portal.content.moveBeforeDOMNode(target.firstChild, target);
2666
2709
  }
2667
2710
  else {
2668
2711
  throw new OwlError("invalid portal target");
@@ -2837,7 +2880,7 @@
2837
2880
  if (__scope) {
2838
2881
  slotScope[__scope] = extra;
2839
2882
  }
2840
- const slotBDom = __render ? __render.call(__ctx.__owl__.component, slotScope, parent, key) : null;
2883
+ const slotBDom = __render ? __render(slotScope, parent, key) : null;
2841
2884
  if (defaultContent) {
2842
2885
  let child1 = undefined;
2843
2886
  let child2 = undefined;
@@ -2845,14 +2888,13 @@
2845
2888
  child1 = dynamic ? toggler(name, slotBDom) : slotBDom;
2846
2889
  }
2847
2890
  else {
2848
- child2 = defaultContent.call(ctx.__owl__.component, ctx, parent, key);
2891
+ child2 = defaultContent(ctx, parent, key);
2849
2892
  }
2850
2893
  return multi([child1, child2]);
2851
2894
  }
2852
2895
  return slotBDom || text("");
2853
2896
  }
2854
- function capture(ctx) {
2855
- const component = ctx.__owl__.component;
2897
+ function capture(ctx, component) {
2856
2898
  const result = ObjectCreate(component);
2857
2899
  for (let k in ctx) {
2858
2900
  result[k] = ctx[k];
@@ -2908,7 +2950,7 @@
2908
2950
  class LazyValue {
2909
2951
  constructor(fn, ctx, component, node, key) {
2910
2952
  this.fn = fn;
2911
- this.ctx = capture(ctx);
2953
+ this.ctx = capture(ctx, component);
2912
2954
  this.component = component;
2913
2955
  this.node = node;
2914
2956
  this.key = key;
@@ -2962,8 +3004,7 @@
2962
3004
  let boundFunctions = new WeakMap();
2963
3005
  const WeakMapGet = WeakMap.prototype.get;
2964
3006
  const WeakMapSet = WeakMap.prototype.set;
2965
- function bind(ctx, fn) {
2966
- let component = ctx.__owl__.component;
3007
+ function bind(component, fn) {
2967
3008
  let boundFnMap = WeakMapGet.call(boundFunctions, component);
2968
3009
  if (!boundFnMap) {
2969
3010
  boundFnMap = new WeakMap();
@@ -3577,7 +3618,7 @@
3577
3618
  let result = [];
3578
3619
  result.push(`function ${this.name}(ctx, node, key = "") {`);
3579
3620
  if (this.hasRef) {
3580
- result.push(` const refs = ctx.__owl__.refs;`);
3621
+ result.push(` const refs = this.__owl__.refs;`);
3581
3622
  for (let name in this.refInfo) {
3582
3623
  const [id, expr] = this.refInfo[name];
3583
3624
  result.push(` const ${id} = ${expr};`);
@@ -3962,39 +4003,6 @@
3962
4003
  attrs[`block-attribute-${selectedId}`] = "selected";
3963
4004
  }
3964
4005
  }
3965
- // event handlers
3966
- for (let ev in ast.on) {
3967
- const name = this.generateHandlerCode(ev, ast.on[ev]);
3968
- const idx = block.insertData(name, "hdlr");
3969
- attrs[`block-handler-${idx}`] = ev;
3970
- }
3971
- // t-ref
3972
- if (ast.ref) {
3973
- this.target.hasRef = true;
3974
- const isDynamic = INTERP_REGEXP.test(ast.ref);
3975
- if (isDynamic) {
3976
- const str = replaceDynamicParts(ast.ref, (expr) => this.captureExpression(expr, true));
3977
- const idx = block.insertData(`(el) => refs[${str}] = el`, "ref");
3978
- attrs["block-ref"] = String(idx);
3979
- }
3980
- else {
3981
- let name = ast.ref;
3982
- if (name in this.target.refInfo) {
3983
- // ref has already been defined
3984
- this.helpers.add("multiRefSetter");
3985
- const info = this.target.refInfo[name];
3986
- const index = block.data.push(info[0]) - 1;
3987
- attrs["block-ref"] = String(index);
3988
- info[1] = `multiRefSetter(refs, \`${name}\`)`;
3989
- }
3990
- else {
3991
- let id = generateId("ref");
3992
- this.target.refInfo[name] = [id, `(el) => refs[\`${name}\`] = el`];
3993
- const index = block.data.push(id) - 1;
3994
- attrs["block-ref"] = String(index);
3995
- }
3996
- }
3997
- }
3998
4006
  // t-model
3999
4007
  let tModelSelectedExpr;
4000
4008
  if (ast.model) {
@@ -4028,6 +4036,39 @@
4028
4036
  idx = block.insertData(handler, "hdlr");
4029
4037
  attrs[`block-handler-${idx}`] = eventType;
4030
4038
  }
4039
+ // event handlers
4040
+ for (let ev in ast.on) {
4041
+ const name = this.generateHandlerCode(ev, ast.on[ev]);
4042
+ const idx = block.insertData(name, "hdlr");
4043
+ attrs[`block-handler-${idx}`] = ev;
4044
+ }
4045
+ // t-ref
4046
+ if (ast.ref) {
4047
+ this.target.hasRef = true;
4048
+ const isDynamic = INTERP_REGEXP.test(ast.ref);
4049
+ if (isDynamic) {
4050
+ const str = replaceDynamicParts(ast.ref, (expr) => this.captureExpression(expr, true));
4051
+ const idx = block.insertData(`(el) => refs[${str}] = el`, "ref");
4052
+ attrs["block-ref"] = String(idx);
4053
+ }
4054
+ else {
4055
+ let name = ast.ref;
4056
+ if (name in this.target.refInfo) {
4057
+ // ref has already been defined
4058
+ this.helpers.add("multiRefSetter");
4059
+ const info = this.target.refInfo[name];
4060
+ const index = block.data.push(info[0]) - 1;
4061
+ attrs["block-ref"] = String(index);
4062
+ info[1] = `multiRefSetter(refs, \`${name}\`)`;
4063
+ }
4064
+ else {
4065
+ let id = generateId("ref");
4066
+ this.target.refInfo[name] = [id, `(el) => refs[\`${name}\`] = el`];
4067
+ const index = block.data.push(id) - 1;
4068
+ attrs["block-ref"] = String(index);
4069
+ }
4070
+ }
4071
+ }
4031
4072
  const dom = xmlDoc.createElement(ast.tag);
4032
4073
  for (const [attr, val] of Object.entries(attrs)) {
4033
4074
  if (!(attr === "class" && val === "")) {
@@ -4218,8 +4259,8 @@
4218
4259
  if (this.dev) {
4219
4260
  // Throw error on duplicate keys in dev mode
4220
4261
  this.helpers.add("OwlError");
4221
- this.addLine(`if (keys${block.id}.has(key${this.target.loopLevel})) { throw new OwlError(\`Got duplicate key in t-foreach: \${key${this.target.loopLevel}}\`)}`);
4222
- this.addLine(`keys${block.id}.add(key${this.target.loopLevel});`);
4262
+ this.addLine(`if (keys${block.id}.has(String(key${this.target.loopLevel}))) { throw new OwlError(\`Got duplicate key in t-foreach: \${key${this.target.loopLevel}}\`)}`);
4263
+ this.addLine(`keys${block.id}.add(String(key${this.target.loopLevel}));`);
4223
4264
  }
4224
4265
  let id;
4225
4266
  if (ast.memo) {
@@ -4436,7 +4477,7 @@
4436
4477
  if (suffix === "bind") {
4437
4478
  this.helpers.add("bind");
4438
4479
  name = _name;
4439
- value = `bind(ctx, ${value || undefined})`;
4480
+ value = `bind(this, ${value || undefined})`;
4440
4481
  }
4441
4482
  else {
4442
4483
  throw new OwlError("Invalid prop suffix");
@@ -4467,7 +4508,7 @@
4467
4508
  if (this.target.loopLevel || !this.hasSafeContext) {
4468
4509
  ctxStr = generateId("ctx");
4469
4510
  this.helpers.add("capture");
4470
- this.define(ctxStr, `capture(ctx)`);
4511
+ this.define(ctxStr, `capture(ctx, this)`);
4471
4512
  }
4472
4513
  let slotStr = [];
4473
4514
  for (let slotName in ast.slots) {
@@ -4475,7 +4516,7 @@
4475
4516
  const params = [];
4476
4517
  if (slotAst.content) {
4477
4518
  const name = this.compileInNewTarget("slot", slotAst.content, ctx, slotAst.on);
4478
- params.push(`__render: ${name}, __ctx: ${ctxStr}`);
4519
+ params.push(`__render: ${name}.bind(this), __ctx: ${ctxStr}`);
4479
4520
  }
4480
4521
  const scope = ast.slots[slotName].scope;
4481
4522
  if (scope) {
@@ -4586,7 +4627,7 @@
4586
4627
  const scope = this.getPropString(props, dynProps);
4587
4628
  if (ast.defaultContent) {
4588
4629
  const name = this.compileInNewTarget("defaultContent", ast.defaultContent, ctx);
4589
- blockString = `callSlot(ctx, node, ${key}, ${slotName}, ${dynamic}, ${scope}, ${name})`;
4630
+ blockString = `callSlot(ctx, node, ${key}, ${slotName}, ${dynamic}, ${scope}, ${name}.bind(this))`;
4590
4631
  }
4591
4632
  else {
4592
4633
  if (dynamic) {
@@ -4626,7 +4667,7 @@
4626
4667
  if (this.target.loopLevel || !this.hasSafeContext) {
4627
4668
  ctxStr = generateId("ctx");
4628
4669
  this.helpers.add("capture");
4629
- this.define(ctxStr, `capture(ctx)`);
4670
+ this.define(ctxStr, `capture(ctx, this)`);
4630
4671
  }
4631
4672
  let id = generateId("comp");
4632
4673
  this.staticDefs.push({
@@ -4634,7 +4675,7 @@
4634
4675
  expr: `app.createComponent(null, false, true, false, false)`,
4635
4676
  });
4636
4677
  const target = compileExpr(ast.target);
4637
- const blockString = `${id}({target: ${target},slots: {'default': {__render: ${name}, __ctx: ${ctxStr}}}}, key + \`${key}\`, node, ctx, Portal)`;
4678
+ const blockString = `${id}({target: ${target},slots: {'default': {__render: ${name}.bind(this), __ctx: ${ctxStr}}}}, key + \`${key}\`, node, ctx, Portal)`;
4638
4679
  if (block) {
4639
4680
  this.insertAnchor(block);
4640
4681
  }
@@ -5167,8 +5208,9 @@
5167
5208
  }
5168
5209
  // default slot
5169
5210
  const defaultContent = parseChildNodes(clone, ctx);
5170
- if (defaultContent) {
5171
- slots = slots || {};
5211
+ slots = slots || {};
5212
+ // t-set-slot="default" has priority over content
5213
+ if (defaultContent && !slots.default) {
5172
5214
  slots.default = { content: defaultContent, on, attrs: null, scope: defaultSlotScope };
5173
5215
  }
5174
5216
  }
@@ -5608,7 +5650,11 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
5608
5650
  else {
5609
5651
  // new component
5610
5652
  if (isStatic) {
5611
- C = parent.constructor.components[name];
5653
+ const components = parent.constructor.components;
5654
+ if (!components) {
5655
+ throw new OwlError(`Cannot find the definition of component "${name}", missing static components key in parent`);
5656
+ }
5657
+ C = components[name];
5612
5658
  if (!C) {
5613
5659
  throw new OwlError(`Cannot find the definition of component "${name}"`);
5614
5660
  }
@@ -5810,9 +5856,9 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
5810
5856
  Object.defineProperty(exports, '__esModule', { value: true });
5811
5857
 
5812
5858
 
5813
- __info__.version = '2.0.0';
5814
- __info__.date = '2022-10-07T13:28:10.216Z';
5815
- __info__.hash = 'a1f2282';
5859
+ __info__.version = '2.0.2';
5860
+ __info__.date = '2022-11-29T14:11:11.260Z';
5861
+ __info__.hash = 'ef8baa2';
5816
5862
  __info__.url = 'https://github.com/odoo/owl';
5817
5863
 
5818
5864