@odoo/owl 2.0.0-beta-8 → 2.0.0-beta-9
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 +91 -65
- package/dist/owl.es.js +91 -65
- package/dist/owl.iife.js +91 -65
- package/dist/owl.iife.min.js +1 -1
- package/dist/types/compiler/code_generator.d.ts +2 -1
- package/dist/types/compiler/inline_expressions.d.ts +1 -0
- package/dist/types/owl.d.ts +520 -0
- package/dist/types/runtime/component_node.d.ts +1 -0
- package/package.json +3 -2
package/dist/owl.iife.js
CHANGED
|
@@ -1290,29 +1290,35 @@
|
|
|
1290
1290
|
}
|
|
1291
1291
|
|
|
1292
1292
|
function createCatcher(eventsSpec) {
|
|
1293
|
-
|
|
1294
|
-
let removeFns = [];
|
|
1295
|
-
for (let name in eventsSpec) {
|
|
1296
|
-
let index = eventsSpec[name];
|
|
1297
|
-
let { setup, remove } = createEventHandler(name);
|
|
1298
|
-
setupFns[index] = setup;
|
|
1299
|
-
removeFns[index] = remove;
|
|
1300
|
-
}
|
|
1301
|
-
let n = setupFns.length;
|
|
1293
|
+
const n = Object.keys(eventsSpec).length;
|
|
1302
1294
|
class VCatcher {
|
|
1303
1295
|
constructor(child, handlers) {
|
|
1296
|
+
this.handlerFns = [];
|
|
1304
1297
|
this.afterNode = null;
|
|
1305
1298
|
this.child = child;
|
|
1306
|
-
this.
|
|
1299
|
+
this.handlerData = handlers;
|
|
1307
1300
|
}
|
|
1308
1301
|
mount(parent, afterNode) {
|
|
1309
1302
|
this.parentEl = parent;
|
|
1310
|
-
this.afterNode = afterNode;
|
|
1311
1303
|
this.child.mount(parent, afterNode);
|
|
1304
|
+
this.afterNode = document.createTextNode("");
|
|
1305
|
+
parent.insertBefore(this.afterNode, afterNode);
|
|
1306
|
+
this.wrapHandlerData();
|
|
1307
|
+
for (let name in eventsSpec) {
|
|
1308
|
+
const index = eventsSpec[name];
|
|
1309
|
+
const handler = createEventHandler(name);
|
|
1310
|
+
this.handlerFns[index] = handler;
|
|
1311
|
+
handler.setup.call(parent, this.handlerData[index]);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
wrapHandlerData() {
|
|
1312
1315
|
for (let i = 0; i < n; i++) {
|
|
1313
|
-
let
|
|
1316
|
+
let handler = this.handlerData[i];
|
|
1317
|
+
// handler = [...mods, fn, comp], so we need to replace second to last elem
|
|
1318
|
+
let idx = handler.length - 2;
|
|
1319
|
+
let origFn = handler[idx];
|
|
1314
1320
|
const self = this;
|
|
1315
|
-
|
|
1321
|
+
handler[idx] = function (ev) {
|
|
1316
1322
|
const target = ev.target;
|
|
1317
1323
|
let currentNode = self.child.firstNode();
|
|
1318
1324
|
const afterNode = self.afterNode;
|
|
@@ -1323,18 +1329,21 @@
|
|
|
1323
1329
|
currentNode = currentNode.nextSibling;
|
|
1324
1330
|
}
|
|
1325
1331
|
};
|
|
1326
|
-
setupFns[i].call(parent, this.handlers[i]);
|
|
1327
1332
|
}
|
|
1328
1333
|
}
|
|
1329
1334
|
moveBefore(other, afterNode) {
|
|
1330
|
-
this.afterNode = null;
|
|
1331
1335
|
this.child.moveBefore(other ? other.child : null, afterNode);
|
|
1336
|
+
this.parentEl.insertBefore(this.afterNode, afterNode);
|
|
1332
1337
|
}
|
|
1333
1338
|
patch(other, withBeforeRemove) {
|
|
1334
1339
|
if (this === other) {
|
|
1335
1340
|
return;
|
|
1336
1341
|
}
|
|
1337
|
-
this.
|
|
1342
|
+
this.handlerData = other.handlerData;
|
|
1343
|
+
this.wrapHandlerData();
|
|
1344
|
+
for (let i = 0; i < n; i++) {
|
|
1345
|
+
this.handlerFns[i].update.call(this.parentEl, this.handlerData[i]);
|
|
1346
|
+
}
|
|
1338
1347
|
this.child.patch(other.child, withBeforeRemove);
|
|
1339
1348
|
}
|
|
1340
1349
|
beforeRemove() {
|
|
@@ -1342,9 +1351,10 @@
|
|
|
1342
1351
|
}
|
|
1343
1352
|
remove() {
|
|
1344
1353
|
for (let i = 0; i < n; i++) {
|
|
1345
|
-
|
|
1354
|
+
this.handlerFns[i].remove.call(this.parentEl);
|
|
1346
1355
|
}
|
|
1347
1356
|
this.child.remove();
|
|
1357
|
+
this.afterNode.remove();
|
|
1348
1358
|
}
|
|
1349
1359
|
firstNode() {
|
|
1350
1360
|
return this.child.firstNode();
|
|
@@ -2177,15 +2187,15 @@
|
|
|
2177
2187
|
}
|
|
2178
2188
|
/**
|
|
2179
2189
|
* Apply default props (only top level).
|
|
2180
|
-
*
|
|
2181
|
-
* Note that this method does modify in place the props
|
|
2182
2190
|
*/
|
|
2183
2191
|
function applyDefaultProps(props, defaultProps) {
|
|
2192
|
+
const result = Object.assign({}, props);
|
|
2184
2193
|
for (let propName in defaultProps) {
|
|
2185
2194
|
if (props[propName] === undefined) {
|
|
2186
|
-
|
|
2195
|
+
result[propName] = defaultProps[propName];
|
|
2187
2196
|
}
|
|
2188
2197
|
}
|
|
2198
|
+
return result;
|
|
2189
2199
|
}
|
|
2190
2200
|
// -----------------------------------------------------------------------------
|
|
2191
2201
|
// Integration with reactivity system (useState)
|
|
@@ -2238,7 +2248,7 @@
|
|
|
2238
2248
|
node.forceNextRender = false;
|
|
2239
2249
|
}
|
|
2240
2250
|
else {
|
|
2241
|
-
const currentProps = node.
|
|
2251
|
+
const currentProps = node.props;
|
|
2242
2252
|
shouldRender = parentFiber.deep || arePropsDifferent(currentProps, props);
|
|
2243
2253
|
}
|
|
2244
2254
|
if (shouldRender) {
|
|
@@ -2285,11 +2295,12 @@
|
|
|
2285
2295
|
currentNode = this;
|
|
2286
2296
|
this.app = app;
|
|
2287
2297
|
this.parent = parent;
|
|
2298
|
+
this.props = props;
|
|
2288
2299
|
this.parentKey = parentKey;
|
|
2289
2300
|
this.level = parent ? parent.level + 1 : 0;
|
|
2290
2301
|
const defaultProps = C.defaultProps;
|
|
2291
2302
|
if (defaultProps) {
|
|
2292
|
-
applyDefaultProps(props, defaultProps);
|
|
2303
|
+
props = applyDefaultProps(props, defaultProps);
|
|
2293
2304
|
}
|
|
2294
2305
|
const env = (parent && parent.childEnv) || app.env;
|
|
2295
2306
|
this.childEnv = env;
|
|
@@ -2400,13 +2411,14 @@
|
|
|
2400
2411
|
this.status = 2 /* DESTROYED */;
|
|
2401
2412
|
}
|
|
2402
2413
|
async updateAndRender(props, parentFiber) {
|
|
2414
|
+
const rawProps = props;
|
|
2403
2415
|
// update
|
|
2404
2416
|
const fiber = makeChildFiber(this, parentFiber);
|
|
2405
2417
|
this.fiber = fiber;
|
|
2406
2418
|
const component = this.component;
|
|
2407
2419
|
const defaultProps = component.constructor.defaultProps;
|
|
2408
2420
|
if (defaultProps) {
|
|
2409
|
-
applyDefaultProps(props, defaultProps);
|
|
2421
|
+
props = applyDefaultProps(props, defaultProps);
|
|
2410
2422
|
}
|
|
2411
2423
|
currentNode = this;
|
|
2412
2424
|
for (const key in props) {
|
|
@@ -2422,6 +2434,7 @@
|
|
|
2422
2434
|
return;
|
|
2423
2435
|
}
|
|
2424
2436
|
component.props = props;
|
|
2437
|
+
this.props = rawProps;
|
|
2425
2438
|
fiber.render();
|
|
2426
2439
|
const parentRoot = parentFiber.root;
|
|
2427
2440
|
if (this.willPatch.length) {
|
|
@@ -2924,22 +2937,33 @@
|
|
|
2924
2937
|
}
|
|
2925
2938
|
let safeKey;
|
|
2926
2939
|
let block;
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2940
|
+
switch (typeof value) {
|
|
2941
|
+
case "object":
|
|
2942
|
+
if (value instanceof Markup) {
|
|
2943
|
+
safeKey = `string_safe`;
|
|
2944
|
+
block = html(value);
|
|
2945
|
+
}
|
|
2946
|
+
else if (value instanceof LazyValue) {
|
|
2947
|
+
safeKey = `lazy_value`;
|
|
2948
|
+
block = value.evaluate();
|
|
2949
|
+
}
|
|
2950
|
+
else if (value instanceof String) {
|
|
2951
|
+
safeKey = "string_unsafe";
|
|
2952
|
+
block = text(value);
|
|
2953
|
+
}
|
|
2954
|
+
else {
|
|
2955
|
+
// Assuming it is a block
|
|
2956
|
+
safeKey = "block_safe";
|
|
2957
|
+
block = value;
|
|
2958
|
+
}
|
|
2959
|
+
break;
|
|
2960
|
+
case "string":
|
|
2961
|
+
safeKey = "string_unsafe";
|
|
2962
|
+
block = text(value);
|
|
2963
|
+
break;
|
|
2964
|
+
default:
|
|
2965
|
+
safeKey = "string_unsafe";
|
|
2966
|
+
block = text(String(value));
|
|
2943
2967
|
}
|
|
2944
2968
|
return toggler(safeKey, block);
|
|
2945
2969
|
}
|
|
@@ -3441,15 +3465,17 @@
|
|
|
3441
3465
|
.map((t) => paddedValues.get(t.value) || t.value)
|
|
3442
3466
|
.join("");
|
|
3443
3467
|
}
|
|
3444
|
-
const INTERP_REGEXP = /\{\{.*?\}\}/g;
|
|
3445
|
-
|
|
3446
|
-
function interpolate(s) {
|
|
3468
|
+
const INTERP_REGEXP = /\{\{.*?\}\}|\#\{.*?\}/g;
|
|
3469
|
+
function replaceDynamicParts(s, replacer) {
|
|
3447
3470
|
let matches = s.match(INTERP_REGEXP);
|
|
3448
3471
|
if (matches && matches[0].length === s.length) {
|
|
3449
|
-
return `(${
|
|
3472
|
+
return `(${replacer(s.slice(2, matches[0][0] === "{" ? -2 : -1))})`;
|
|
3450
3473
|
}
|
|
3451
|
-
let r = s.replace(
|
|
3474
|
+
let r = s.replace(INTERP_REGEXP, (s) => "${" + replacer(s.slice(2, s[0] === "{" ? -2 : -1)) + "}");
|
|
3452
3475
|
return "`" + r + "`";
|
|
3476
|
+
}
|
|
3477
|
+
function interpolate(s) {
|
|
3478
|
+
return replaceDynamicParts(s, compileExpr);
|
|
3453
3479
|
}
|
|
3454
3480
|
|
|
3455
3481
|
// using a non-html document so that <inner/outer>HTML serializes as XML instead
|
|
@@ -3949,8 +3975,8 @@
|
|
|
3949
3975
|
this.target.hasRef = true;
|
|
3950
3976
|
const isDynamic = INTERP_REGEXP.test(ast.ref);
|
|
3951
3977
|
if (isDynamic) {
|
|
3952
|
-
const str = ast.ref
|
|
3953
|
-
const idx = block.insertData(`(el) => refs[
|
|
3978
|
+
const str = replaceDynamicParts(ast.ref, (expr) => this.captureExpression(expr, true));
|
|
3979
|
+
const idx = block.insertData(`(el) => refs[${str}] = el`, "ref");
|
|
3954
3980
|
attrs["block-ref"] = String(idx);
|
|
3955
3981
|
}
|
|
3956
3982
|
else {
|
|
@@ -4400,21 +4426,20 @@
|
|
|
4400
4426
|
return `${name}: ${value || undefined}`;
|
|
4401
4427
|
}
|
|
4402
4428
|
formatPropObject(obj) {
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4429
|
+
return Object.entries(obj).map(([k, v]) => this.formatProp(k, v));
|
|
4430
|
+
}
|
|
4431
|
+
getPropString(props, dynProps) {
|
|
4432
|
+
let propString = `{${props.join(",")}}`;
|
|
4433
|
+
if (dynProps) {
|
|
4434
|
+
propString = `Object.assign({}, ${compileExpr(dynProps)}${props.length ? ", " + propString : ""})`;
|
|
4406
4435
|
}
|
|
4407
|
-
return
|
|
4436
|
+
return propString;
|
|
4408
4437
|
}
|
|
4409
4438
|
compileComponent(ast, ctx) {
|
|
4410
4439
|
let { block } = ctx;
|
|
4411
4440
|
// props
|
|
4412
4441
|
const hasSlotsProp = "slots" in (ast.props || {});
|
|
4413
|
-
const props = [];
|
|
4414
|
-
const propExpr = this.formatPropObject(ast.props || {});
|
|
4415
|
-
if (propExpr) {
|
|
4416
|
-
props.push(propExpr);
|
|
4417
|
-
}
|
|
4442
|
+
const props = ast.props ? this.formatPropObject(ast.props) : [];
|
|
4418
4443
|
// slots
|
|
4419
4444
|
let slotDef = "";
|
|
4420
4445
|
if (ast.slots) {
|
|
@@ -4437,7 +4462,7 @@
|
|
|
4437
4462
|
params.push(`__scope: "${scope}"`);
|
|
4438
4463
|
}
|
|
4439
4464
|
if (ast.slots[slotName].attrs) {
|
|
4440
|
-
params.push(this.formatPropObject(ast.slots[slotName].attrs));
|
|
4465
|
+
params.push(...this.formatPropObject(ast.slots[slotName].attrs));
|
|
4441
4466
|
}
|
|
4442
4467
|
const slotInfo = `{${params.join(", ")}}`;
|
|
4443
4468
|
slotStr.push(`'${slotName}': ${slotInfo}`);
|
|
@@ -4448,11 +4473,7 @@
|
|
|
4448
4473
|
this.helpers.add("markRaw");
|
|
4449
4474
|
props.push(`slots: markRaw(${slotDef})`);
|
|
4450
4475
|
}
|
|
4451
|
-
|
|
4452
|
-
let propString = propStr;
|
|
4453
|
-
if (ast.dynamicProps) {
|
|
4454
|
-
propString = `Object.assign({}, ${compileExpr(ast.dynamicProps)}${props.length ? ", " + propStr : ""})`;
|
|
4455
|
-
}
|
|
4476
|
+
let propString = this.getPropString(props, ast.dynamicProps);
|
|
4456
4477
|
let propVar;
|
|
4457
4478
|
if ((slotDef && (ast.dynamicProps || hasSlotsProp)) || this.dev) {
|
|
4458
4479
|
propVar = generateId("props");
|
|
@@ -4524,7 +4545,12 @@
|
|
|
4524
4545
|
else {
|
|
4525
4546
|
slotName = "'" + ast.name + "'";
|
|
4526
4547
|
}
|
|
4527
|
-
const
|
|
4548
|
+
const dynProps = ast.attrs ? ast.attrs["t-props"] : null;
|
|
4549
|
+
if (ast.attrs) {
|
|
4550
|
+
delete ast.attrs["t-props"];
|
|
4551
|
+
}
|
|
4552
|
+
const props = ast.attrs ? this.formatPropObject(ast.attrs) : [];
|
|
4553
|
+
const scope = this.getPropString(props, dynProps);
|
|
4528
4554
|
if (ast.defaultContent) {
|
|
4529
4555
|
const name = this.compileInNewTarget("defaultContent", ast.defaultContent, ctx);
|
|
4530
4556
|
blockString = `callSlot(ctx, node, key, ${slotName}, ${dynamic}, ${scope}, ${name})`;
|
|
@@ -5693,9 +5719,9 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
|
|
|
5693
5719
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5694
5720
|
|
|
5695
5721
|
|
|
5696
|
-
__info__.version = '2.0.0-beta-
|
|
5697
|
-
__info__.date = '2022-
|
|
5698
|
-
__info__.hash = '
|
|
5722
|
+
__info__.version = '2.0.0-beta-9';
|
|
5723
|
+
__info__.date = '2022-06-09T12:32:25.382Z';
|
|
5724
|
+
__info__.hash = '83d4471';
|
|
5699
5725
|
__info__.url = 'https://github.com/odoo/owl';
|
|
5700
5726
|
|
|
5701
5727
|
|