@odoo/owl 3.0.0-alpha.29 → 3.0.0-alpha.30
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 +111 -462
- package/dist/owl.es.js +111 -462
- package/dist/owl.iife.js +111 -462
- package/dist/owl.iife.min.js +12 -12
- package/dist/types/owl.d.ts +5 -5
- package/package.json +4 -4
package/dist/owl.cjs.js
CHANGED
|
@@ -74,8 +74,7 @@ __export(index_exports, {
|
|
|
74
74
|
});
|
|
75
75
|
module.exports = __toCommonJS(index_exports);
|
|
76
76
|
|
|
77
|
-
// ../owl-
|
|
78
|
-
var version = "3.0.0-alpha.29";
|
|
77
|
+
// ../owl-core/dist/owl-core.es.js
|
|
79
78
|
var OwlError = class extends Error {
|
|
80
79
|
cause;
|
|
81
80
|
};
|
|
@@ -93,7 +92,7 @@ function batched(callback) {
|
|
|
93
92
|
return function batchedCall(...args) {
|
|
94
93
|
if (!scheduled) {
|
|
95
94
|
scheduled = true;
|
|
96
|
-
|
|
95
|
+
Promise.resolve().then(() => {
|
|
97
96
|
scheduled = false;
|
|
98
97
|
callback(...args);
|
|
99
98
|
});
|
|
@@ -141,10 +140,11 @@ function onWriteAtom(atom) {
|
|
|
141
140
|
}
|
|
142
141
|
var batchProcessEffects = batched(processEffects);
|
|
143
142
|
function processEffects() {
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
const pending = observers;
|
|
144
|
+
observers = [];
|
|
145
|
+
for (let i = 0; i < pending.length; i++) {
|
|
146
|
+
updateComputation(pending[i]);
|
|
146
147
|
}
|
|
147
|
-
observers.length = 0;
|
|
148
148
|
}
|
|
149
149
|
function getCurrentComputation() {
|
|
150
150
|
return currentComputation;
|
|
@@ -163,6 +163,9 @@ function updateComputation(computation) {
|
|
|
163
163
|
continue;
|
|
164
164
|
}
|
|
165
165
|
updateComputation(source);
|
|
166
|
+
if (computation.state === 1) {
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
166
169
|
}
|
|
167
170
|
if (computation.state !== 1) {
|
|
168
171
|
computation.state = 0;
|
|
@@ -172,15 +175,18 @@ function updateComputation(computation) {
|
|
|
172
175
|
removeSources(computation);
|
|
173
176
|
const previousComputation = currentComputation;
|
|
174
177
|
currentComputation = computation;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
try {
|
|
179
|
+
computation.value = computation.compute();
|
|
180
|
+
computation.state = 0;
|
|
181
|
+
} finally {
|
|
182
|
+
currentComputation = previousComputation;
|
|
183
|
+
}
|
|
178
184
|
}
|
|
179
185
|
function removeSources(computation) {
|
|
180
186
|
const sources = computation.sources;
|
|
181
187
|
for (const source of sources) {
|
|
182
|
-
const
|
|
183
|
-
|
|
188
|
+
const observers2 = source.observers;
|
|
189
|
+
observers2.delete(computation);
|
|
184
190
|
}
|
|
185
191
|
sources.clear();
|
|
186
192
|
}
|
|
@@ -444,10 +450,10 @@ function proxifyTarget(target, atom) {
|
|
|
444
450
|
} else {
|
|
445
451
|
handler = basicProxyHandler(atom);
|
|
446
452
|
}
|
|
447
|
-
const
|
|
448
|
-
proxyCache.set(target,
|
|
449
|
-
targets.set(
|
|
450
|
-
return
|
|
453
|
+
const proxy2 = new Proxy(target, handler);
|
|
454
|
+
proxyCache.set(target, proxy2);
|
|
455
|
+
targets.set(proxy2, target);
|
|
456
|
+
return proxy2;
|
|
451
457
|
}
|
|
452
458
|
function proxy(target) {
|
|
453
459
|
return proxifyTarget(target, null);
|
|
@@ -629,11 +635,11 @@ function buildSignal(value, set) {
|
|
|
629
635
|
};
|
|
630
636
|
return readSignal;
|
|
631
637
|
}
|
|
632
|
-
function triggerSignal(
|
|
633
|
-
if (typeof
|
|
634
|
-
throw new OwlError(`Value is not a signal (${
|
|
638
|
+
function triggerSignal(signal2) {
|
|
639
|
+
if (typeof signal2 !== "function" || signal2[atomSymbol]?.type !== "signal") {
|
|
640
|
+
throw new OwlError(`Value is not a signal (${signal2})`);
|
|
635
641
|
}
|
|
636
|
-
onWriteAtom(
|
|
642
|
+
onWriteAtom(signal2[atomSymbol]);
|
|
637
643
|
}
|
|
638
644
|
function signalArray(initialValue) {
|
|
639
645
|
return buildSignal(initialValue, (atom) => proxifyTarget(atom.value, atom));
|
|
@@ -1259,6 +1265,9 @@ function startPlugins(manager, plugins) {
|
|
|
1259
1265
|
);
|
|
1260
1266
|
}
|
|
1261
1267
|
}
|
|
1268
|
+
|
|
1269
|
+
// ../owl-runtime/dist/owl-runtime.es.js
|
|
1270
|
+
var version = "3.0.0-alpha.30";
|
|
1262
1271
|
var fibersInError = /* @__PURE__ */ new WeakMap();
|
|
1263
1272
|
var nodeErrorHandlers = /* @__PURE__ */ new WeakMap();
|
|
1264
1273
|
function invokeErrorHandlers(node, error, finalize, markFibers) {
|
|
@@ -1314,12 +1323,7 @@ function handleError(params) {
|
|
|
1314
1323
|
app.destroy();
|
|
1315
1324
|
} catch (e) {
|
|
1316
1325
|
}
|
|
1317
|
-
|
|
1318
|
-
return error;
|
|
1319
|
-
}
|
|
1320
|
-
return Object.assign(new OwlError(`[Owl] Unhandled error. Destroying the root component`), {
|
|
1321
|
-
cause: error
|
|
1322
|
-
});
|
|
1326
|
+
return error;
|
|
1323
1327
|
};
|
|
1324
1328
|
const result = invokeErrorHandlers(node, error, finalize, true);
|
|
1325
1329
|
if (!result.handled) {
|
|
@@ -3039,8 +3043,9 @@ var Fiber = class {
|
|
|
3039
3043
|
this.bdom = node.renderFn();
|
|
3040
3044
|
} catch (e) {
|
|
3041
3045
|
handleError({ node, error: e });
|
|
3046
|
+
} finally {
|
|
3047
|
+
setComputation(c);
|
|
3042
3048
|
}
|
|
3043
|
-
setComputation(c);
|
|
3044
3049
|
const newCounter = root.counter - 1;
|
|
3045
3050
|
root.counter = newCounter;
|
|
3046
3051
|
if (newCounter === 0) {
|
|
@@ -3246,7 +3251,6 @@ var ComponentNode = class extends Scope {
|
|
|
3246
3251
|
setComputation(prev);
|
|
3247
3252
|
await Promise.all(promises);
|
|
3248
3253
|
} catch (e) {
|
|
3249
|
-
setComputation(prev);
|
|
3250
3254
|
if (isAbortError(e) && this.status > STATUS.MOUNTED) {
|
|
3251
3255
|
return;
|
|
3252
3256
|
}
|
|
@@ -3600,7 +3604,10 @@ function createRef(ref2) {
|
|
|
3600
3604
|
remove2 = ref2.delete.bind(ref2);
|
|
3601
3605
|
} else if (ref2.set) {
|
|
3602
3606
|
add = ref2.set.bind(ref2);
|
|
3603
|
-
|
|
3607
|
+
const atom = ref2[atomSymbol];
|
|
3608
|
+
remove2 = atom ? (prevEl) => {
|
|
3609
|
+
if (atom.value === prevEl) ref2.set(null);
|
|
3610
|
+
} : () => ref2.set(null);
|
|
3604
3611
|
} else {
|
|
3605
3612
|
throw new OwlError(
|
|
3606
3613
|
`Ref should implement either a 'set' function or 'add' and 'delete' functions`
|
|
@@ -3694,12 +3701,13 @@ function createComponent(app, name, isStatic, hasSlotsProp, hasDynamicPropList,
|
|
|
3694
3701
|
if (node.patched.length) parentRoot.patched.push(fiber);
|
|
3695
3702
|
let promises;
|
|
3696
3703
|
if (hooks.length) {
|
|
3704
|
+
let nextProps = props2;
|
|
3697
3705
|
const defaultProps = node.defaultProps;
|
|
3698
3706
|
if (defaultProps) {
|
|
3699
|
-
|
|
3707
|
+
nextProps = Object.assign({}, props2);
|
|
3700
3708
|
for (const k in defaultProps) {
|
|
3701
|
-
if (
|
|
3702
|
-
|
|
3709
|
+
if (nextProps[k] === void 0) {
|
|
3710
|
+
nextProps[k] = defaultProps[k];
|
|
3703
3711
|
}
|
|
3704
3712
|
}
|
|
3705
3713
|
}
|
|
@@ -3707,7 +3715,7 @@ function createComponent(app, name, isStatic, hasSlotsProp, hasDynamicPropList,
|
|
|
3707
3715
|
const prev = getCurrentComputation();
|
|
3708
3716
|
setComputation(void 0);
|
|
3709
3717
|
for (const f of hooks) {
|
|
3710
|
-
const r = f.call(component,
|
|
3718
|
+
const r = f.call(component, nextProps);
|
|
3711
3719
|
if (r && typeof r.then === "function") {
|
|
3712
3720
|
(promises ||= []).push(r);
|
|
3713
3721
|
}
|
|
@@ -3827,9 +3835,7 @@ var TemplateSet = class {
|
|
|
3827
3835
|
return;
|
|
3828
3836
|
}
|
|
3829
3837
|
const rawTemplate = this.rawTemplates[name];
|
|
3830
|
-
|
|
3831
|
-
const newAsString = typeof template === "string" ? template : template.outerHTML;
|
|
3832
|
-
if (currentAsString === newAsString) {
|
|
3838
|
+
if (areTemplatesEqual(rawTemplate, template)) {
|
|
3833
3839
|
return;
|
|
3834
3840
|
}
|
|
3835
3841
|
throw new OwlError(`Template ${name} already defined with different content`);
|
|
@@ -3886,6 +3892,17 @@ function xml(...args) {
|
|
|
3886
3892
|
return name;
|
|
3887
3893
|
}
|
|
3888
3894
|
xml.nextId = 1;
|
|
3895
|
+
function areTemplatesEqual(t1, t2) {
|
|
3896
|
+
if (t1 === t2) {
|
|
3897
|
+
return true;
|
|
3898
|
+
}
|
|
3899
|
+
if (typeof t1 === "function" !== (typeof t2 === "function")) {
|
|
3900
|
+
return false;
|
|
3901
|
+
}
|
|
3902
|
+
const s1 = t1 instanceof Element ? t1.outerHTML : String(t1);
|
|
3903
|
+
const s2 = t2 instanceof Element ? t2.outerHTML : String(t2);
|
|
3904
|
+
return s1 === s2;
|
|
3905
|
+
}
|
|
3889
3906
|
var hasBeenLogged = false;
|
|
3890
3907
|
var apps = /* @__PURE__ */ new Set();
|
|
3891
3908
|
if (typeof window !== "undefined") {
|
|
@@ -4145,6 +4162,9 @@ function props(type, defaults) {
|
|
|
4145
4162
|
if (app.dev) {
|
|
4146
4163
|
const validation = defaults ? validateObjectWithDefaults(type, defaults) : types2.object(type);
|
|
4147
4164
|
assertType(node.props, validation, `Invalid component props (${componentName})`);
|
|
4165
|
+
if (defaults) {
|
|
4166
|
+
assertType(defaults, validation, `Invalid default props (${componentName})`);
|
|
4167
|
+
}
|
|
4148
4168
|
node.willUpdateProps.push((np) => {
|
|
4149
4169
|
assertType(np, validation, `Invalid component props (${componentName})`);
|
|
4150
4170
|
});
|
|
@@ -4365,396 +4385,12 @@ var blockDom = {
|
|
|
4365
4385
|
};
|
|
4366
4386
|
var __info__ = {
|
|
4367
4387
|
version: App.version,
|
|
4368
|
-
date: "2026-
|
|
4369
|
-
hash: "
|
|
4388
|
+
date: "2026-05-19T14:24:07.068Z",
|
|
4389
|
+
hash: "a826de4f",
|
|
4370
4390
|
url: "https://github.com/odoo/owl"
|
|
4371
4391
|
};
|
|
4372
4392
|
|
|
4373
4393
|
// ../owl-compiler/dist/owl-compiler.es.js
|
|
4374
|
-
var OwlError2 = class extends Error {
|
|
4375
|
-
cause;
|
|
4376
|
-
};
|
|
4377
|
-
function batched2(callback) {
|
|
4378
|
-
let scheduled = false;
|
|
4379
|
-
return function batchedCall(...args) {
|
|
4380
|
-
if (!scheduled) {
|
|
4381
|
-
scheduled = true;
|
|
4382
|
-
queueMicrotask(() => {
|
|
4383
|
-
scheduled = false;
|
|
4384
|
-
callback(...args);
|
|
4385
|
-
});
|
|
4386
|
-
}
|
|
4387
|
-
};
|
|
4388
|
-
}
|
|
4389
|
-
var atomSymbol2 = /* @__PURE__ */ Symbol("Atom");
|
|
4390
|
-
var observers2 = [];
|
|
4391
|
-
var currentComputation2;
|
|
4392
|
-
function onReadAtom2(atom) {
|
|
4393
|
-
if (!currentComputation2) {
|
|
4394
|
-
return;
|
|
4395
|
-
}
|
|
4396
|
-
currentComputation2.sources.add(atom);
|
|
4397
|
-
atom.observers.add(currentComputation2);
|
|
4398
|
-
}
|
|
4399
|
-
function onWriteAtom2(atom) {
|
|
4400
|
-
for (const ctx of atom.observers) {
|
|
4401
|
-
if (ctx.state === 0) {
|
|
4402
|
-
if (ctx.isDerived) {
|
|
4403
|
-
markDownstream2(ctx);
|
|
4404
|
-
} else {
|
|
4405
|
-
observers2.push(ctx);
|
|
4406
|
-
}
|
|
4407
|
-
}
|
|
4408
|
-
ctx.state = 1;
|
|
4409
|
-
}
|
|
4410
|
-
batchProcessEffects2();
|
|
4411
|
-
}
|
|
4412
|
-
var batchProcessEffects2 = batched2(processEffects2);
|
|
4413
|
-
function processEffects2() {
|
|
4414
|
-
for (let i = 0; i < observers2.length; i++) {
|
|
4415
|
-
updateComputation2(observers2[i]);
|
|
4416
|
-
}
|
|
4417
|
-
observers2.length = 0;
|
|
4418
|
-
}
|
|
4419
|
-
function updateComputation2(computation) {
|
|
4420
|
-
const state = computation.state;
|
|
4421
|
-
if (state === 0) {
|
|
4422
|
-
return;
|
|
4423
|
-
}
|
|
4424
|
-
if (state === 2) {
|
|
4425
|
-
for (const source of computation.sources) {
|
|
4426
|
-
if (!("compute" in source)) {
|
|
4427
|
-
continue;
|
|
4428
|
-
}
|
|
4429
|
-
updateComputation2(source);
|
|
4430
|
-
}
|
|
4431
|
-
if (computation.state !== 1) {
|
|
4432
|
-
computation.state = 0;
|
|
4433
|
-
return;
|
|
4434
|
-
}
|
|
4435
|
-
}
|
|
4436
|
-
removeSources2(computation);
|
|
4437
|
-
const previousComputation = currentComputation2;
|
|
4438
|
-
currentComputation2 = computation;
|
|
4439
|
-
computation.value = computation.compute();
|
|
4440
|
-
computation.state = 0;
|
|
4441
|
-
currentComputation2 = previousComputation;
|
|
4442
|
-
}
|
|
4443
|
-
function removeSources2(computation) {
|
|
4444
|
-
const sources = computation.sources;
|
|
4445
|
-
for (const source of sources) {
|
|
4446
|
-
const observers22 = source.observers;
|
|
4447
|
-
observers22.delete(computation);
|
|
4448
|
-
}
|
|
4449
|
-
sources.clear();
|
|
4450
|
-
}
|
|
4451
|
-
function markDownstream2(computation) {
|
|
4452
|
-
const stack = [computation];
|
|
4453
|
-
let current;
|
|
4454
|
-
while (current = stack.pop()) {
|
|
4455
|
-
for (const observer of current.observers) {
|
|
4456
|
-
if (observer.state) {
|
|
4457
|
-
continue;
|
|
4458
|
-
}
|
|
4459
|
-
observer.state = 2;
|
|
4460
|
-
if (observer.isDerived) {
|
|
4461
|
-
stack.push(observer);
|
|
4462
|
-
} else {
|
|
4463
|
-
observers2.push(observer);
|
|
4464
|
-
}
|
|
4465
|
-
}
|
|
4466
|
-
}
|
|
4467
|
-
}
|
|
4468
|
-
var KEYCHANGES2 = /* @__PURE__ */ Symbol("Key changes");
|
|
4469
|
-
var objectToString2 = Object.prototype.toString;
|
|
4470
|
-
var objectHasOwnProperty2 = Object.prototype.hasOwnProperty;
|
|
4471
|
-
function canBeMadeReactive2(value) {
|
|
4472
|
-
if (typeof value !== "object" || value === null) {
|
|
4473
|
-
return false;
|
|
4474
|
-
}
|
|
4475
|
-
const raw = toRaw2(value);
|
|
4476
|
-
if (Array.isArray(raw) || raw instanceof Set || raw instanceof Map || raw instanceof WeakMap) {
|
|
4477
|
-
return true;
|
|
4478
|
-
}
|
|
4479
|
-
return objectToString2.call(raw) === "[object Object]";
|
|
4480
|
-
}
|
|
4481
|
-
function possiblyReactive2(val, atom) {
|
|
4482
|
-
return !atom && canBeMadeReactive2(val) ? proxy2(val) : val;
|
|
4483
|
-
}
|
|
4484
|
-
var skipped2 = /* @__PURE__ */ new WeakSet();
|
|
4485
|
-
function toRaw2(value) {
|
|
4486
|
-
return targets2.has(value) ? targets2.get(value) : value;
|
|
4487
|
-
}
|
|
4488
|
-
var targetToKeysToAtomItem2 = /* @__PURE__ */ new WeakMap();
|
|
4489
|
-
function getTargetKeyAtom2(target, key) {
|
|
4490
|
-
let keyToAtomItem = targetToKeysToAtomItem2.get(target);
|
|
4491
|
-
if (!keyToAtomItem) {
|
|
4492
|
-
keyToAtomItem = /* @__PURE__ */ new Map();
|
|
4493
|
-
targetToKeysToAtomItem2.set(target, keyToAtomItem);
|
|
4494
|
-
}
|
|
4495
|
-
let atom = keyToAtomItem.get(key);
|
|
4496
|
-
if (!atom) {
|
|
4497
|
-
atom = {
|
|
4498
|
-
value: void 0,
|
|
4499
|
-
observers: /* @__PURE__ */ new Set()
|
|
4500
|
-
};
|
|
4501
|
-
keyToAtomItem.set(key, atom);
|
|
4502
|
-
}
|
|
4503
|
-
return atom;
|
|
4504
|
-
}
|
|
4505
|
-
function onReadTargetKey2(target, key, atom) {
|
|
4506
|
-
onReadAtom2(atom ?? getTargetKeyAtom2(target, key));
|
|
4507
|
-
}
|
|
4508
|
-
function onWriteTargetKey2(target, key, atom) {
|
|
4509
|
-
if (!atom) {
|
|
4510
|
-
const keyToAtomItem = targetToKeysToAtomItem2.get(target);
|
|
4511
|
-
if (!keyToAtomItem) {
|
|
4512
|
-
return;
|
|
4513
|
-
}
|
|
4514
|
-
if (!keyToAtomItem.has(key)) {
|
|
4515
|
-
return;
|
|
4516
|
-
}
|
|
4517
|
-
atom = keyToAtomItem.get(key);
|
|
4518
|
-
}
|
|
4519
|
-
onWriteAtom2(atom);
|
|
4520
|
-
}
|
|
4521
|
-
var targets2 = /* @__PURE__ */ new WeakMap();
|
|
4522
|
-
var proxyCache2 = /* @__PURE__ */ new WeakMap();
|
|
4523
|
-
function proxifyTarget2(target, atom) {
|
|
4524
|
-
if (!canBeMadeReactive2(target)) {
|
|
4525
|
-
throw new OwlError2(`Cannot make the given value reactive`);
|
|
4526
|
-
}
|
|
4527
|
-
if (skipped2.has(target)) {
|
|
4528
|
-
return target;
|
|
4529
|
-
}
|
|
4530
|
-
if (targets2.has(target)) {
|
|
4531
|
-
return target;
|
|
4532
|
-
}
|
|
4533
|
-
const reactive = proxyCache2.get(target);
|
|
4534
|
-
if (reactive) {
|
|
4535
|
-
return reactive;
|
|
4536
|
-
}
|
|
4537
|
-
let handler;
|
|
4538
|
-
if (target instanceof Map) {
|
|
4539
|
-
handler = collectionsProxyHandler2(target, "Map", atom);
|
|
4540
|
-
} else if (target instanceof Set) {
|
|
4541
|
-
handler = collectionsProxyHandler2(target, "Set", atom);
|
|
4542
|
-
} else if (target instanceof WeakMap) {
|
|
4543
|
-
handler = collectionsProxyHandler2(target, "WeakMap", atom);
|
|
4544
|
-
} else {
|
|
4545
|
-
handler = basicProxyHandler2(atom);
|
|
4546
|
-
}
|
|
4547
|
-
const proxy22 = new Proxy(target, handler);
|
|
4548
|
-
proxyCache2.set(target, proxy22);
|
|
4549
|
-
targets2.set(proxy22, target);
|
|
4550
|
-
return proxy22;
|
|
4551
|
-
}
|
|
4552
|
-
function proxy2(target) {
|
|
4553
|
-
return proxifyTarget2(target, null);
|
|
4554
|
-
}
|
|
4555
|
-
function basicProxyHandler2(atom) {
|
|
4556
|
-
return {
|
|
4557
|
-
get(target, key, receiver) {
|
|
4558
|
-
onReadTargetKey2(target, key, atom);
|
|
4559
|
-
const value = Reflect.get(target, key, receiver);
|
|
4560
|
-
if (atom || typeof value !== "object" || value === null) {
|
|
4561
|
-
return value;
|
|
4562
|
-
}
|
|
4563
|
-
if (!canBeMadeReactive2(value)) {
|
|
4564
|
-
return value;
|
|
4565
|
-
}
|
|
4566
|
-
const desc = Object.getOwnPropertyDescriptor(target, key);
|
|
4567
|
-
if (desc && !desc.writable && !desc.configurable) {
|
|
4568
|
-
return value;
|
|
4569
|
-
}
|
|
4570
|
-
return proxifyTarget2(value, null);
|
|
4571
|
-
},
|
|
4572
|
-
set(target, key, value, receiver) {
|
|
4573
|
-
const hadKey = objectHasOwnProperty2.call(target, key);
|
|
4574
|
-
const originalValue = Reflect.get(target, key, receiver);
|
|
4575
|
-
const ret = Reflect.set(target, key, toRaw2(value), receiver);
|
|
4576
|
-
if (!hadKey && objectHasOwnProperty2.call(target, key)) {
|
|
4577
|
-
onWriteTargetKey2(target, KEYCHANGES2, atom);
|
|
4578
|
-
}
|
|
4579
|
-
if (originalValue !== Reflect.get(target, key, receiver) || key === "length" && Array.isArray(target)) {
|
|
4580
|
-
onWriteTargetKey2(target, key, atom);
|
|
4581
|
-
}
|
|
4582
|
-
return ret;
|
|
4583
|
-
},
|
|
4584
|
-
deleteProperty(target, key) {
|
|
4585
|
-
const ret = Reflect.deleteProperty(target, key);
|
|
4586
|
-
onWriteTargetKey2(target, KEYCHANGES2, atom);
|
|
4587
|
-
onWriteTargetKey2(target, key, atom);
|
|
4588
|
-
return ret;
|
|
4589
|
-
},
|
|
4590
|
-
ownKeys(target) {
|
|
4591
|
-
onReadTargetKey2(target, KEYCHANGES2, atom);
|
|
4592
|
-
return Reflect.ownKeys(target);
|
|
4593
|
-
},
|
|
4594
|
-
has(target, key) {
|
|
4595
|
-
onReadTargetKey2(target, KEYCHANGES2, atom);
|
|
4596
|
-
return Reflect.has(target, key);
|
|
4597
|
-
}
|
|
4598
|
-
};
|
|
4599
|
-
}
|
|
4600
|
-
function makeKeyObserver2(methodName, target, atom) {
|
|
4601
|
-
return (key) => {
|
|
4602
|
-
key = toRaw2(key);
|
|
4603
|
-
onReadTargetKey2(target, key, atom);
|
|
4604
|
-
return possiblyReactive2(target[methodName](key), atom);
|
|
4605
|
-
};
|
|
4606
|
-
}
|
|
4607
|
-
function makeIteratorObserver2(methodName, target, atom) {
|
|
4608
|
-
return function* () {
|
|
4609
|
-
onReadTargetKey2(target, KEYCHANGES2, atom);
|
|
4610
|
-
const keys = target.keys();
|
|
4611
|
-
for (const item of target[methodName]()) {
|
|
4612
|
-
const key = keys.next().value;
|
|
4613
|
-
onReadTargetKey2(target, key, atom);
|
|
4614
|
-
yield possiblyReactive2(item, atom);
|
|
4615
|
-
}
|
|
4616
|
-
};
|
|
4617
|
-
}
|
|
4618
|
-
function makeForEachObserver2(target, atom) {
|
|
4619
|
-
return function forEach(forEachCb, thisArg) {
|
|
4620
|
-
onReadTargetKey2(target, KEYCHANGES2, atom);
|
|
4621
|
-
target.forEach(function(val, key, targetObj) {
|
|
4622
|
-
onReadTargetKey2(target, key, atom);
|
|
4623
|
-
forEachCb.call(
|
|
4624
|
-
thisArg,
|
|
4625
|
-
possiblyReactive2(val, atom),
|
|
4626
|
-
possiblyReactive2(key, atom),
|
|
4627
|
-
possiblyReactive2(targetObj, atom)
|
|
4628
|
-
);
|
|
4629
|
-
}, thisArg);
|
|
4630
|
-
};
|
|
4631
|
-
}
|
|
4632
|
-
function delegateAndNotify2(setterName, getterName, target, atom) {
|
|
4633
|
-
return (key, value) => {
|
|
4634
|
-
key = toRaw2(key);
|
|
4635
|
-
const hadKey = target.has(key);
|
|
4636
|
-
const originalValue = target[getterName](key);
|
|
4637
|
-
const ret = target[setterName](key, value);
|
|
4638
|
-
const hasKey = target.has(key);
|
|
4639
|
-
if (hadKey !== hasKey) {
|
|
4640
|
-
onWriteTargetKey2(target, KEYCHANGES2, atom);
|
|
4641
|
-
}
|
|
4642
|
-
if (originalValue !== target[getterName](key)) {
|
|
4643
|
-
onWriteTargetKey2(target, key, atom);
|
|
4644
|
-
}
|
|
4645
|
-
return ret;
|
|
4646
|
-
};
|
|
4647
|
-
}
|
|
4648
|
-
function makeClearNotifier2(target, atom) {
|
|
4649
|
-
return () => {
|
|
4650
|
-
const allKeys = [...target.keys()];
|
|
4651
|
-
target.clear();
|
|
4652
|
-
onWriteTargetKey2(target, KEYCHANGES2, atom);
|
|
4653
|
-
for (const key of allKeys) {
|
|
4654
|
-
onWriteTargetKey2(target, key, atom);
|
|
4655
|
-
}
|
|
4656
|
-
};
|
|
4657
|
-
}
|
|
4658
|
-
var rawTypeToFuncHandlers2 = {
|
|
4659
|
-
Set: (target, atom) => ({
|
|
4660
|
-
has: makeKeyObserver2("has", target, atom),
|
|
4661
|
-
add: delegateAndNotify2("add", "has", target, atom),
|
|
4662
|
-
delete: delegateAndNotify2("delete", "has", target, atom),
|
|
4663
|
-
keys: makeIteratorObserver2("keys", target, atom),
|
|
4664
|
-
values: makeIteratorObserver2("values", target, atom),
|
|
4665
|
-
entries: makeIteratorObserver2("entries", target, atom),
|
|
4666
|
-
[Symbol.iterator]: makeIteratorObserver2(Symbol.iterator, target, atom),
|
|
4667
|
-
forEach: makeForEachObserver2(target, atom),
|
|
4668
|
-
clear: makeClearNotifier2(target, atom),
|
|
4669
|
-
get size() {
|
|
4670
|
-
onReadTargetKey2(target, KEYCHANGES2, atom);
|
|
4671
|
-
return target.size;
|
|
4672
|
-
}
|
|
4673
|
-
}),
|
|
4674
|
-
Map: (target, atom) => ({
|
|
4675
|
-
has: makeKeyObserver2("has", target, atom),
|
|
4676
|
-
get: makeKeyObserver2("get", target, atom),
|
|
4677
|
-
set: delegateAndNotify2("set", "get", target, atom),
|
|
4678
|
-
delete: delegateAndNotify2("delete", "has", target, atom),
|
|
4679
|
-
keys: makeIteratorObserver2("keys", target, atom),
|
|
4680
|
-
values: makeIteratorObserver2("values", target, atom),
|
|
4681
|
-
entries: makeIteratorObserver2("entries", target, atom),
|
|
4682
|
-
[Symbol.iterator]: makeIteratorObserver2(Symbol.iterator, target, atom),
|
|
4683
|
-
forEach: makeForEachObserver2(target, atom),
|
|
4684
|
-
clear: makeClearNotifier2(target, atom),
|
|
4685
|
-
get size() {
|
|
4686
|
-
onReadTargetKey2(target, KEYCHANGES2, atom);
|
|
4687
|
-
return target.size;
|
|
4688
|
-
}
|
|
4689
|
-
}),
|
|
4690
|
-
WeakMap: (target, atom) => ({
|
|
4691
|
-
has: makeKeyObserver2("has", target, atom),
|
|
4692
|
-
get: makeKeyObserver2("get", target, atom),
|
|
4693
|
-
set: delegateAndNotify2("set", "get", target, atom),
|
|
4694
|
-
delete: delegateAndNotify2("delete", "has", target, atom)
|
|
4695
|
-
})
|
|
4696
|
-
};
|
|
4697
|
-
function collectionsProxyHandler2(target, targetRawType, atom) {
|
|
4698
|
-
const specialHandlers = rawTypeToFuncHandlers2[targetRawType](target, atom);
|
|
4699
|
-
return Object.assign(basicProxyHandler2(atom), {
|
|
4700
|
-
// FIXME: probably broken when part of prototype chain since we ignore the receiver
|
|
4701
|
-
get(target2, key) {
|
|
4702
|
-
if (objectHasOwnProperty2.call(specialHandlers, key)) {
|
|
4703
|
-
return specialHandlers[key];
|
|
4704
|
-
}
|
|
4705
|
-
onReadTargetKey2(target2, key, atom);
|
|
4706
|
-
return possiblyReactive2(target2[key], atom);
|
|
4707
|
-
}
|
|
4708
|
-
});
|
|
4709
|
-
}
|
|
4710
|
-
function buildSignal2(value, set) {
|
|
4711
|
-
const atom = {
|
|
4712
|
-
type: "signal",
|
|
4713
|
-
value,
|
|
4714
|
-
observers: /* @__PURE__ */ new Set()
|
|
4715
|
-
};
|
|
4716
|
-
let readValue = set(atom);
|
|
4717
|
-
const readSignal = () => {
|
|
4718
|
-
onReadAtom2(atom);
|
|
4719
|
-
return readValue;
|
|
4720
|
-
};
|
|
4721
|
-
readSignal[atomSymbol2] = atom;
|
|
4722
|
-
readSignal.set = function writeSignal(newValue) {
|
|
4723
|
-
if (Object.is(atom.value, newValue)) {
|
|
4724
|
-
return;
|
|
4725
|
-
}
|
|
4726
|
-
atom.value = newValue;
|
|
4727
|
-
readValue = set(atom);
|
|
4728
|
-
onWriteAtom2(atom);
|
|
4729
|
-
};
|
|
4730
|
-
return readSignal;
|
|
4731
|
-
}
|
|
4732
|
-
function triggerSignal2(signal22) {
|
|
4733
|
-
if (typeof signal22 !== "function" || signal22[atomSymbol2]?.type !== "signal") {
|
|
4734
|
-
throw new OwlError2(`Value is not a signal (${signal22})`);
|
|
4735
|
-
}
|
|
4736
|
-
onWriteAtom2(signal22[atomSymbol2]);
|
|
4737
|
-
}
|
|
4738
|
-
function signalArray2(initialValue) {
|
|
4739
|
-
return buildSignal2(initialValue, (atom) => proxifyTarget2(atom.value, atom));
|
|
4740
|
-
}
|
|
4741
|
-
function signalObject2(initialValue) {
|
|
4742
|
-
return buildSignal2(initialValue, (atom) => proxifyTarget2(atom.value, atom));
|
|
4743
|
-
}
|
|
4744
|
-
function signalMap2(initialValue) {
|
|
4745
|
-
return buildSignal2(initialValue, (atom) => proxifyTarget2(atom.value, atom));
|
|
4746
|
-
}
|
|
4747
|
-
function signalSet2(initialValue) {
|
|
4748
|
-
return buildSignal2(initialValue, (atom) => proxifyTarget2(atom.value, atom));
|
|
4749
|
-
}
|
|
4750
|
-
function signal2(value) {
|
|
4751
|
-
return buildSignal2(value, (atom) => atom.value);
|
|
4752
|
-
}
|
|
4753
|
-
signal2.trigger = triggerSignal2;
|
|
4754
|
-
signal2.Array = signalArray2;
|
|
4755
|
-
signal2.Map = signalMap2;
|
|
4756
|
-
signal2.Object = signalObject2;
|
|
4757
|
-
signal2.Set = signalSet2;
|
|
4758
4394
|
var RESERVED_WORDS = "true,false,NaN,null,undefined,debugger,console,window,in,instanceof,new,function,return,eval,void,Math,RegExp,Array,Object,Date,__globals__".split(
|
|
4759
4395
|
","
|
|
4760
4396
|
);
|
|
@@ -4792,14 +4428,14 @@ var tokenizeString = function(expr) {
|
|
|
4792
4428
|
i++;
|
|
4793
4429
|
cur = expr[i];
|
|
4794
4430
|
if (!cur) {
|
|
4795
|
-
throw new
|
|
4431
|
+
throw new OwlError("Invalid expression");
|
|
4796
4432
|
}
|
|
4797
4433
|
s += cur;
|
|
4798
4434
|
}
|
|
4799
4435
|
i++;
|
|
4800
4436
|
}
|
|
4801
4437
|
if (expr[i] !== start) {
|
|
4802
|
-
throw new
|
|
4438
|
+
throw new OwlError("Invalid expression");
|
|
4803
4439
|
}
|
|
4804
4440
|
s += start;
|
|
4805
4441
|
if (start === "`") {
|
|
@@ -4891,19 +4527,25 @@ function tokenize(expr) {
|
|
|
4891
4527
|
error = e;
|
|
4892
4528
|
}
|
|
4893
4529
|
if (current.length || error) {
|
|
4894
|
-
throw new
|
|
4530
|
+
throw new OwlError(`Tokenizer error: could not tokenize \`${expr}\``);
|
|
4895
4531
|
}
|
|
4896
4532
|
return result;
|
|
4897
4533
|
}
|
|
4898
4534
|
var isLeftSeparator = (token) => token && (token.type === "LEFT_BRACE" || token.type === "COMMA");
|
|
4899
4535
|
var isRightSeparator = (token) => token && (token.type === "RIGHT_BRACE" || token.type === "COMMA");
|
|
4900
4536
|
var paddedValues = /* @__PURE__ */ new Map([["in ", " in "]]);
|
|
4901
|
-
function processExpr(expr) {
|
|
4902
|
-
const
|
|
4537
|
+
function processExpr(expr, seededLocals) {
|
|
4538
|
+
const scopeStack2 = [];
|
|
4539
|
+
if (seededLocals?.size) {
|
|
4540
|
+
scopeStack2.push({ vars: seededLocals, depth: -Infinity });
|
|
4541
|
+
}
|
|
4903
4542
|
const tokens = tokenize(expr);
|
|
4904
4543
|
let i = 0;
|
|
4905
4544
|
let stack = [];
|
|
4906
4545
|
let topLevelArrowIndex = -1;
|
|
4546
|
+
function isLocal(name) {
|
|
4547
|
+
return scopeStack2.some((s) => s.vars.has(name));
|
|
4548
|
+
}
|
|
4907
4549
|
while (i < tokens.length) {
|
|
4908
4550
|
let token = tokens[i];
|
|
4909
4551
|
let prevToken = tokens[i - 1];
|
|
@@ -4919,6 +4561,10 @@ function processExpr(expr) {
|
|
|
4919
4561
|
case "RIGHT_BRACKET":
|
|
4920
4562
|
case "RIGHT_PAREN":
|
|
4921
4563
|
stack.pop();
|
|
4564
|
+
while (scopeStack2.length > 0 && stack.length < scopeStack2[scopeStack2.length - 1].depth) {
|
|
4565
|
+
scopeStack2.pop();
|
|
4566
|
+
}
|
|
4567
|
+
break;
|
|
4922
4568
|
}
|
|
4923
4569
|
let isVar = token.type === "SYMBOL" && !RESERVED_WORDS.includes(token.value);
|
|
4924
4570
|
if (isVar) {
|
|
@@ -4937,9 +4583,14 @@ function processExpr(expr) {
|
|
|
4937
4583
|
}
|
|
4938
4584
|
}
|
|
4939
4585
|
if (token.type === "TEMPLATE_STRING") {
|
|
4940
|
-
|
|
4586
|
+
const currentLocals = /* @__PURE__ */ new Set();
|
|
4587
|
+
for (const scope of scopeStack2) {
|
|
4588
|
+
for (const v of scope.vars) currentLocals.add(v);
|
|
4589
|
+
}
|
|
4590
|
+
token.value = token.replace((expr2) => compileExpr(expr2, currentLocals));
|
|
4941
4591
|
}
|
|
4942
4592
|
if (nextToken && nextToken.type === "OPERATOR" && nextToken.value === "=>") {
|
|
4593
|
+
const newScope = /* @__PURE__ */ new Set();
|
|
4943
4594
|
if (stack.length === 0) {
|
|
4944
4595
|
topLevelArrowIndex = i + 1;
|
|
4945
4596
|
}
|
|
@@ -4947,31 +4598,29 @@ function processExpr(expr) {
|
|
|
4947
4598
|
let j = i - 1;
|
|
4948
4599
|
while (j > 0 && tokens[j].type !== "LEFT_PAREN") {
|
|
4949
4600
|
if (tokens[j].type === "SYMBOL" && tokens[j].originalValue) {
|
|
4950
|
-
|
|
4951
|
-
|
|
4601
|
+
newScope.add(tokens[j].originalValue);
|
|
4602
|
+
tokens[j].value = `_${tokens[j].originalValue}`;
|
|
4603
|
+
tokens[j].isLocal = true;
|
|
4952
4604
|
}
|
|
4953
4605
|
j--;
|
|
4954
4606
|
}
|
|
4955
4607
|
} else {
|
|
4956
|
-
|
|
4608
|
+
newScope.add(token.value);
|
|
4957
4609
|
}
|
|
4610
|
+
scopeStack2.push({ vars: newScope, depth: stack.length });
|
|
4958
4611
|
}
|
|
4959
4612
|
if (isVar) {
|
|
4960
4613
|
token.varName = token.value;
|
|
4961
|
-
if (!
|
|
4614
|
+
if (!isLocal(token.value)) {
|
|
4962
4615
|
token.originalValue = token.value;
|
|
4963
4616
|
token.value = `ctx['${token.value}']`;
|
|
4617
|
+
} else {
|
|
4618
|
+
token.value = `_${token.value}`;
|
|
4619
|
+
token.isLocal = true;
|
|
4964
4620
|
}
|
|
4965
4621
|
}
|
|
4966
4622
|
i++;
|
|
4967
4623
|
}
|
|
4968
|
-
for (const token of tokens) {
|
|
4969
|
-
if (token.type === "SYMBOL" && token.varName && localVars.has(token.value)) {
|
|
4970
|
-
token.originalValue = token.value;
|
|
4971
|
-
token.value = `_${token.value}`;
|
|
4972
|
-
token.isLocal = true;
|
|
4973
|
-
}
|
|
4974
|
-
}
|
|
4975
4624
|
let freeVariables = null;
|
|
4976
4625
|
if (topLevelArrowIndex !== -1) {
|
|
4977
4626
|
freeVariables = [];
|
|
@@ -4987,8 +4636,8 @@ function processExpr(expr) {
|
|
|
4987
4636
|
const compiled = tokens.map((t) => paddedValues.get(t.value) || t.value).join("");
|
|
4988
4637
|
return { expr: compiled, freeVariables };
|
|
4989
4638
|
}
|
|
4990
|
-
function compileExpr(expr) {
|
|
4991
|
-
return processExpr(expr).expr;
|
|
4639
|
+
function compileExpr(expr, seededLocals) {
|
|
4640
|
+
return processExpr(expr, seededLocals).expr;
|
|
4992
4641
|
}
|
|
4993
4642
|
var INTERP_REGEXP = /\{\{.*?\}\}|\#\{.*?\}/g;
|
|
4994
4643
|
function replaceDynamicParts(s, replacer) {
|
|
@@ -5030,7 +4679,7 @@ ${"-".repeat(columnIndex - 1)}^`;
|
|
|
5030
4679
|
}
|
|
5031
4680
|
}
|
|
5032
4681
|
}
|
|
5033
|
-
throw new
|
|
4682
|
+
throw new OwlError(msg);
|
|
5034
4683
|
}
|
|
5035
4684
|
return doc;
|
|
5036
4685
|
}
|
|
@@ -5109,13 +4758,13 @@ function parseTCustom(node, ctx) {
|
|
|
5109
4758
|
const nodeAttrsNames = node.getAttributeNames();
|
|
5110
4759
|
for (let attr of nodeAttrsNames) {
|
|
5111
4760
|
if (attr === "t-custom" || attr === "t-custom-") {
|
|
5112
|
-
throw new
|
|
4761
|
+
throw new OwlError("Missing custom directive name with t-custom directive");
|
|
5113
4762
|
}
|
|
5114
4763
|
if (attr.startsWith("t-custom-")) {
|
|
5115
4764
|
const directiveName = attr.split(".")[0].slice(9);
|
|
5116
4765
|
const customDirective = ctx.customDirectives[directiveName];
|
|
5117
4766
|
if (!customDirective) {
|
|
5118
|
-
throw new
|
|
4767
|
+
throw new OwlError(`Custom directive "${directiveName}" is not defined`);
|
|
5119
4768
|
}
|
|
5120
4769
|
const value = node.getAttribute(attr);
|
|
5121
4770
|
const modifiers = attr.split(".").slice(1);
|
|
@@ -5123,7 +4772,7 @@ function parseTCustom(node, ctx) {
|
|
|
5123
4772
|
try {
|
|
5124
4773
|
customDirective(node, value, modifiers);
|
|
5125
4774
|
} catch (error) {
|
|
5126
|
-
throw new
|
|
4775
|
+
throw new OwlError(
|
|
5127
4776
|
`Custom directive "${directiveName}" throw the following error: ${error}`
|
|
5128
4777
|
);
|
|
5129
4778
|
}
|
|
@@ -5170,7 +4819,7 @@ function parseDOMNode(node, ctx) {
|
|
|
5170
4819
|
return null;
|
|
5171
4820
|
}
|
|
5172
4821
|
if (tagName.startsWith("block-")) {
|
|
5173
|
-
throw new
|
|
4822
|
+
throw new OwlError(`Invalid tag name: '${tagName}'`);
|
|
5174
4823
|
}
|
|
5175
4824
|
ctx = Object.assign({}, ctx);
|
|
5176
4825
|
if (tagName === "pre") {
|
|
@@ -5187,14 +4836,14 @@ function parseDOMNode(node, ctx) {
|
|
|
5187
4836
|
for (let attr of nodeAttrsNames) {
|
|
5188
4837
|
const value = node.getAttribute(attr);
|
|
5189
4838
|
if (attr === "t-on" || attr === "t-on-") {
|
|
5190
|
-
throw new
|
|
4839
|
+
throw new OwlError("Missing event name with t-on directive");
|
|
5191
4840
|
}
|
|
5192
4841
|
if (attr.startsWith("t-on-")) {
|
|
5193
4842
|
on = on || {};
|
|
5194
4843
|
on[attr.slice(5)] = value;
|
|
5195
4844
|
} else if (attr.startsWith("t-model")) {
|
|
5196
4845
|
if (!["input", "select", "textarea"].includes(tagName)) {
|
|
5197
|
-
throw new
|
|
4846
|
+
throw new OwlError(
|
|
5198
4847
|
"The t-model directive only works with <input>, <textarea> and <select>"
|
|
5199
4848
|
);
|
|
5200
4849
|
}
|
|
@@ -5223,7 +4872,7 @@ function parseDOMNode(node, ctx) {
|
|
|
5223
4872
|
ctx.tModelInfo = model;
|
|
5224
4873
|
}
|
|
5225
4874
|
} else if (attr.startsWith("block-")) {
|
|
5226
|
-
throw new
|
|
4875
|
+
throw new OwlError(`Invalid attribute: '${attr}'`);
|
|
5227
4876
|
} else if (attr === "xmlns") {
|
|
5228
4877
|
ns = value;
|
|
5229
4878
|
} else if (attr.startsWith("t-translation-context-")) {
|
|
@@ -5232,7 +4881,7 @@ function parseDOMNode(node, ctx) {
|
|
|
5232
4881
|
attrsTranslationCtx[attrName] = value;
|
|
5233
4882
|
} else if (attr !== "t-name") {
|
|
5234
4883
|
if (attr.startsWith("t-") && !attr.startsWith("t-att")) {
|
|
5235
|
-
throw new
|
|
4884
|
+
throw new OwlError(`Unknown QWeb directive: '${attr}'`);
|
|
5236
4885
|
}
|
|
5237
4886
|
const tModel = ctx.tModelInfo;
|
|
5238
4887
|
if (tModel && ["t-att-value", "t-attf-value"].includes(attr)) {
|
|
@@ -5299,7 +4948,7 @@ function parseTForEach(node, ctx) {
|
|
|
5299
4948
|
node.removeAttribute("t-as");
|
|
5300
4949
|
const key = node.getAttribute("t-key");
|
|
5301
4950
|
if (!key) {
|
|
5302
|
-
throw new
|
|
4951
|
+
throw new OwlError(
|
|
5303
4952
|
`"Directive t-foreach should always be used with a t-key!" (expression: t-foreach="${collection}" t-as="${elem}")`
|
|
5304
4953
|
);
|
|
5305
4954
|
}
|
|
@@ -5348,7 +4997,7 @@ function parseTCall(node, ctx) {
|
|
|
5348
4997
|
return null;
|
|
5349
4998
|
}
|
|
5350
4999
|
if (node.tagName !== "t") {
|
|
5351
|
-
throw new
|
|
5000
|
+
throw new OwlError(
|
|
5352
5001
|
`Directive 't-call' can only be used on <t> nodes (used on a <${node.tagName}>)`
|
|
5353
5002
|
);
|
|
5354
5003
|
}
|
|
@@ -5452,7 +5101,7 @@ function parseComponent(node, ctx) {
|
|
|
5452
5101
|
const firstLetter = name[0];
|
|
5453
5102
|
let isDynamic = node.hasAttribute("t-component");
|
|
5454
5103
|
if (isDynamic && name !== "t") {
|
|
5455
|
-
throw new
|
|
5104
|
+
throw new OwlError(
|
|
5456
5105
|
`Directive 't-component' can only be used on <t> nodes (used on a <${name}>)`
|
|
5457
5106
|
);
|
|
5458
5107
|
}
|
|
@@ -5482,7 +5131,7 @@ function parseComponent(node, ctx) {
|
|
|
5482
5131
|
on[name2.slice(5)] = value;
|
|
5483
5132
|
} else {
|
|
5484
5133
|
const message = directiveErrorMap.get(name2.split("-").slice(0, 2).join("-"));
|
|
5485
|
-
throw new
|
|
5134
|
+
throw new OwlError(message || `unsupported directive on Component: ${name2}`);
|
|
5486
5135
|
}
|
|
5487
5136
|
} else {
|
|
5488
5137
|
props2 = props2 || {};
|
|
@@ -5495,7 +5144,7 @@ function parseComponent(node, ctx) {
|
|
|
5495
5144
|
const slotNodes = Array.from(clone.querySelectorAll("[t-set-slot]"));
|
|
5496
5145
|
for (let slotNode of slotNodes) {
|
|
5497
5146
|
if (slotNode.tagName !== "t") {
|
|
5498
|
-
throw new
|
|
5147
|
+
throw new OwlError(
|
|
5499
5148
|
`Directive 't-set-slot' can only be used on <t> nodes (used on a <${slotNode.tagName}>)`
|
|
5500
5149
|
);
|
|
5501
5150
|
}
|
|
@@ -5682,24 +5331,24 @@ function normalizeTIf(el) {
|
|
|
5682
5331
|
let nattr = (name) => +!!node.getAttribute(name);
|
|
5683
5332
|
if (prevElem && (pattr("t-if") || pattr("t-elif"))) {
|
|
5684
5333
|
if (pattr("t-foreach")) {
|
|
5685
|
-
throw new
|
|
5334
|
+
throw new OwlError(
|
|
5686
5335
|
"t-if cannot stay at the same level as t-foreach when using t-elif or t-else"
|
|
5687
5336
|
);
|
|
5688
5337
|
}
|
|
5689
5338
|
if (["t-if", "t-elif", "t-else"].map(nattr).reduce(function(a, b) {
|
|
5690
5339
|
return a + b;
|
|
5691
5340
|
}) > 1) {
|
|
5692
|
-
throw new
|
|
5341
|
+
throw new OwlError("Only one conditional branching directive is allowed per node");
|
|
5693
5342
|
}
|
|
5694
5343
|
let textNode;
|
|
5695
5344
|
while ((textNode = node.previousSibling) !== prevElem) {
|
|
5696
5345
|
if (textNode.nodeValue.trim().length && textNode.nodeType !== 8) {
|
|
5697
|
-
throw new
|
|
5346
|
+
throw new OwlError("text is not allowed between branching directives");
|
|
5698
5347
|
}
|
|
5699
5348
|
textNode.remove();
|
|
5700
5349
|
}
|
|
5701
5350
|
} else {
|
|
5702
|
-
throw new
|
|
5351
|
+
throw new OwlError(
|
|
5703
5352
|
"t-elif and t-else directives must be preceded by a t-if or t-elif directive"
|
|
5704
5353
|
);
|
|
5705
5354
|
}
|
|
@@ -5711,7 +5360,7 @@ function normalizeTOut(el) {
|
|
|
5711
5360
|
);
|
|
5712
5361
|
for (const el2 of elements) {
|
|
5713
5362
|
if (el2.childNodes.length) {
|
|
5714
|
-
throw new
|
|
5363
|
+
throw new OwlError(`Cannot have t-out on a component that already has content`);
|
|
5715
5364
|
}
|
|
5716
5365
|
const value = el2.getAttribute("t-out");
|
|
5717
5366
|
el2.removeAttribute("t-out");
|
|
@@ -6118,7 +5767,7 @@ ${code}`;
|
|
|
6118
5767
|
generateHandlerCode(rawEvent, handler) {
|
|
6119
5768
|
const modifiers = rawEvent.split(".").slice(1).map((m) => {
|
|
6120
5769
|
if (!MODS.has(m)) {
|
|
6121
|
-
throw new
|
|
5770
|
+
throw new OwlError(`Unknown event modifier: '${m}'`);
|
|
6122
5771
|
}
|
|
6123
5772
|
return `"${m}"`;
|
|
6124
5773
|
});
|
|
@@ -6669,7 +6318,7 @@ ${code}`;
|
|
|
6669
6318
|
case "translate":
|
|
6670
6319
|
break;
|
|
6671
6320
|
default:
|
|
6672
|
-
throw new
|
|
6321
|
+
throw new OwlError(`Invalid prop suffix: ${suffix}`);
|
|
6673
6322
|
}
|
|
6674
6323
|
}
|
|
6675
6324
|
name = /^[a-z_]+$/i.test(name) ? name : `'${name}'`;
|
|
@@ -6885,7 +6534,7 @@ function compile(template, options = {
|
|
|
6885
6534
|
} catch (originalError) {
|
|
6886
6535
|
const { name } = options;
|
|
6887
6536
|
const nameStr = name ? `template "${name}"` : "anonymous template";
|
|
6888
|
-
const err = new
|
|
6537
|
+
const err = new OwlError(
|
|
6889
6538
|
`Failed to compile ${nameStr}: ${originalError.message}
|
|
6890
6539
|
|
|
6891
6540
|
generated code:
|