@odoo/owl 1.4.5 → 1.4.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/README.md +1 -1
- package/dist/owl.cjs.js +56 -35
- package/dist/owl.cjs.min.js +3 -3
- package/dist/owl.es.js +53 -32
- package/dist/owl.es.min.js +3 -3
- package/dist/owl.iife.js +59 -36
- package/dist/owl.iife.min.js +2 -2
- package/dist/types/qweb/expression_parser.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -124,7 +124,7 @@ npm install @odoo/owl
|
|
|
124
124
|
|
|
125
125
|
If you want to use a simple `<script>` tag, the last release can be downloaded here:
|
|
126
126
|
|
|
127
|
-
- [owl-1.4.
|
|
127
|
+
- [owl-1.4.9](https://github.com/odoo/owl/releases/tag/v1.4.9)
|
|
128
128
|
|
|
129
129
|
## License
|
|
130
130
|
|
package/dist/owl.cjs.js
CHANGED
|
@@ -360,6 +360,7 @@ const isRightSeparator = (token) => token && (token.type === "RIGHT_BRACE" || to
|
|
|
360
360
|
* the list of variables so it does not get replaced by a lookup in the context
|
|
361
361
|
*/
|
|
362
362
|
function compileExprToArray(expr, scope) {
|
|
363
|
+
const localVars = new Set();
|
|
363
364
|
scope = Object.create(scope);
|
|
364
365
|
const tokens = tokenize(expr);
|
|
365
366
|
let i = 0;
|
|
@@ -385,7 +386,7 @@ function compileExprToArray(expr, scope) {
|
|
|
385
386
|
if (groupType === "LEFT_BRACE" &&
|
|
386
387
|
isLeftSeparator(prevToken) &&
|
|
387
388
|
isRightSeparator(nextToken)) {
|
|
388
|
-
tokens.splice(i + 1, 0, { type: "COLON", value: ":" }, {
|
|
389
|
+
tokens.splice(i + 1, 0, { type: "COLON", value: ":" }, Object.assign({}, token));
|
|
389
390
|
nextToken = tokens[i + 1];
|
|
390
391
|
}
|
|
391
392
|
if (prevToken.type === "OPERATOR" && prevToken.value === ".") {
|
|
@@ -408,12 +409,14 @@ function compileExprToArray(expr, scope) {
|
|
|
408
409
|
if (tokens[j].type === "SYMBOL" && tokens[j].originalValue) {
|
|
409
410
|
tokens[j].value = tokens[j].originalValue;
|
|
410
411
|
scope[tokens[j].value] = { id: tokens[j].value, expr: tokens[j].value };
|
|
412
|
+
localVars.add(tokens[j].value);
|
|
411
413
|
}
|
|
412
414
|
j--;
|
|
413
415
|
}
|
|
414
416
|
}
|
|
415
417
|
else {
|
|
416
418
|
scope[token.value] = { id: token.value, expr: token.value };
|
|
419
|
+
localVars.add(token.value);
|
|
417
420
|
}
|
|
418
421
|
}
|
|
419
422
|
if (isVar) {
|
|
@@ -428,6 +431,13 @@ function compileExprToArray(expr, scope) {
|
|
|
428
431
|
}
|
|
429
432
|
i++;
|
|
430
433
|
}
|
|
434
|
+
// Mark all variables that have been used locally.
|
|
435
|
+
// This assumes the expression has only one scope (incorrect but "good enough for now")
|
|
436
|
+
for (const token of tokens) {
|
|
437
|
+
if (token.type === "SYMBOL" && localVars.has(token.value)) {
|
|
438
|
+
token.isLocal = true;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
431
441
|
return tokens;
|
|
432
442
|
}
|
|
433
443
|
function compileExpr(expr, scope) {
|
|
@@ -579,7 +589,18 @@ class CompilationContext {
|
|
|
579
589
|
const done = new Set();
|
|
580
590
|
return tokens
|
|
581
591
|
.map((tok) => {
|
|
582
|
-
|
|
592
|
+
// "this" in captured expressions should be the current component
|
|
593
|
+
if (tok.value === "this") {
|
|
594
|
+
if (!done.has("this")) {
|
|
595
|
+
done.add("this");
|
|
596
|
+
this.addLine(`const this_${argId} = utils.getComponent(context);`);
|
|
597
|
+
}
|
|
598
|
+
tok.value = `this_${argId}`;
|
|
599
|
+
}
|
|
600
|
+
// Variables that should be looked up in the scope. isLocal is for arrow
|
|
601
|
+
// function arguments that should stay untouched (eg "ev => ev" should
|
|
602
|
+
// not become "const ev_1 = scope['ev']; ev_1 => ev_1")
|
|
603
|
+
if (tok.varName && !tok.isLocal) {
|
|
583
604
|
if (!done.has(tok.varName)) {
|
|
584
605
|
done.add(tok.varName);
|
|
585
606
|
this.addLine(`const ${tok.varName}_${argId} = ${tok.value};`);
|
|
@@ -892,16 +913,16 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
|
892
913
|
}
|
|
893
914
|
return map;
|
|
894
915
|
}
|
|
895
|
-
const hooks = ["create", "update", "remove", "destroy", "pre", "post"];
|
|
916
|
+
const hooks$1 = ["create", "update", "remove", "destroy", "pre", "post"];
|
|
896
917
|
function init(modules, domApi) {
|
|
897
918
|
let i, j, cbs = {};
|
|
898
919
|
const api = domApi !== undefined ? domApi : htmlDomApi;
|
|
899
|
-
for (i = 0; i < hooks.length; ++i) {
|
|
900
|
-
cbs[hooks[i]] = [];
|
|
920
|
+
for (i = 0; i < hooks$1.length; ++i) {
|
|
921
|
+
cbs[hooks$1[i]] = [];
|
|
901
922
|
for (j = 0; j < modules.length; ++j) {
|
|
902
|
-
const hook = modules[j][hooks[i]];
|
|
923
|
+
const hook = modules[j][hooks$1[i]];
|
|
903
924
|
if (hook !== undefined) {
|
|
904
|
-
cbs[hooks[i]].push(hook);
|
|
925
|
+
cbs[hooks$1[i]].push(hook);
|
|
905
926
|
}
|
|
906
927
|
}
|
|
907
928
|
}
|
|
@@ -2510,7 +2531,8 @@ QWeb.addDirective({
|
|
|
2510
2531
|
ctx.addLine(`if (!_${arrayID}) { throw new Error('QWeb error: Invalid loop expression')}`);
|
|
2511
2532
|
let keysID = ctx.generateID();
|
|
2512
2533
|
let valuesID = ctx.generateID();
|
|
2513
|
-
ctx.addLine(`let _${keysID} = _${
|
|
2534
|
+
ctx.addLine(`let _${keysID} = _${arrayID};`);
|
|
2535
|
+
ctx.addLine(`let _${valuesID} = _${arrayID};`);
|
|
2514
2536
|
ctx.addIf(`!(_${arrayID} instanceof Array)`);
|
|
2515
2537
|
ctx.addLine(`_${keysID} = Object.keys(_${arrayID});`);
|
|
2516
2538
|
ctx.addLine(`_${valuesID} = Object.values(_${arrayID});`);
|
|
@@ -2924,9 +2946,6 @@ Object.defineProperty(config, "mode", {
|
|
|
2924
2946
|
This is not suitable for production use.
|
|
2925
2947
|
See https://github.com/odoo/owl/blob/master/doc/reference/config.md#mode for more information.`);
|
|
2926
2948
|
}
|
|
2927
|
-
else {
|
|
2928
|
-
console.log(`Owl is now running in 'prod' mode.`);
|
|
2929
|
-
}
|
|
2930
2949
|
},
|
|
2931
2950
|
});
|
|
2932
2951
|
Object.defineProperty(config, "enableTransitions", {
|
|
@@ -3179,7 +3198,12 @@ QWeb.addDirective({
|
|
|
3179
3198
|
else if (!name.startsWith("t-")) {
|
|
3180
3199
|
if (name !== "class" && name !== "style") {
|
|
3181
3200
|
// this is a prop!
|
|
3182
|
-
|
|
3201
|
+
if (value.includes("=>")) {
|
|
3202
|
+
props[name] = ctx.captureExpression(value);
|
|
3203
|
+
}
|
|
3204
|
+
else {
|
|
3205
|
+
props[name] = ctx.formatExpression(value) || "undefined";
|
|
3206
|
+
}
|
|
3183
3207
|
}
|
|
3184
3208
|
}
|
|
3185
3209
|
}
|
|
@@ -3662,6 +3686,7 @@ class Fiber {
|
|
|
3662
3686
|
// build patchQueue
|
|
3663
3687
|
const patchQueue = [];
|
|
3664
3688
|
const doWork = function (f) {
|
|
3689
|
+
f.component.__owl__.currentFiber = null;
|
|
3665
3690
|
patchQueue.push(f);
|
|
3666
3691
|
return f.child;
|
|
3667
3692
|
};
|
|
@@ -3704,8 +3729,9 @@ class Fiber {
|
|
|
3704
3729
|
component.__patch(target, fiber.vnode);
|
|
3705
3730
|
}
|
|
3706
3731
|
else {
|
|
3707
|
-
|
|
3708
|
-
|
|
3732
|
+
const vnode = component.__owl__.vnode;
|
|
3733
|
+
if (fiber.shouldPatch && vnode) {
|
|
3734
|
+
component.__patch(vnode, fiber.vnode);
|
|
3709
3735
|
// When updating a Component's props (in directive),
|
|
3710
3736
|
// the component has a pvnode AND should be patched.
|
|
3711
3737
|
// However, its pvnode.elm may have changed if it is a High Order Component
|
|
@@ -3718,10 +3744,6 @@ class Fiber {
|
|
|
3718
3744
|
component.__owl__.pvnode.elm = component.__owl__.vnode.elm;
|
|
3719
3745
|
}
|
|
3720
3746
|
}
|
|
3721
|
-
const compOwl = component.__owl__;
|
|
3722
|
-
if (fiber === compOwl.currentFiber) {
|
|
3723
|
-
compOwl.currentFiber = null;
|
|
3724
|
-
}
|
|
3725
3747
|
}
|
|
3726
3748
|
// insert into the DOM (mount case)
|
|
3727
3749
|
let inDOM = false;
|
|
@@ -4375,7 +4397,6 @@ class Component {
|
|
|
4375
4397
|
__callMounted() {
|
|
4376
4398
|
const __owl__ = this.__owl__;
|
|
4377
4399
|
__owl__.status = 3 /* MOUNTED */;
|
|
4378
|
-
__owl__.currentFiber = null;
|
|
4379
4400
|
this.mounted();
|
|
4380
4401
|
if (__owl__.mountedCB) {
|
|
4381
4402
|
__owl__.mountedCB();
|
|
@@ -4668,7 +4689,7 @@ function partitionBy(arr, fn) {
|
|
|
4668
4689
|
return acc;
|
|
4669
4690
|
}, []);
|
|
4670
4691
|
}
|
|
4671
|
-
class Context extends EventBus {
|
|
4692
|
+
class Context$1 extends EventBus {
|
|
4672
4693
|
constructor(state = {}) {
|
|
4673
4694
|
super();
|
|
4674
4695
|
this.rev = 1;
|
|
@@ -4781,7 +4802,7 @@ function useContextWithCB(ctx, component, method) {
|
|
|
4781
4802
|
* will return an observed object (or array). Changes to that value will then
|
|
4782
4803
|
* trigger a rerendering of the current component.
|
|
4783
4804
|
*/
|
|
4784
|
-
function useState(state) {
|
|
4805
|
+
function useState$1(state) {
|
|
4785
4806
|
const component = Component.current;
|
|
4786
4807
|
const __owl__ = component.__owl__;
|
|
4787
4808
|
if (!__owl__.observer) {
|
|
@@ -4917,7 +4938,7 @@ function useExternalListener(target, eventName, handler, eventParams) {
|
|
|
4917
4938
|
|
|
4918
4939
|
var _hooks = /*#__PURE__*/Object.freeze({
|
|
4919
4940
|
__proto__: null,
|
|
4920
|
-
useState: useState,
|
|
4941
|
+
useState: useState$1,
|
|
4921
4942
|
onMounted: onMounted,
|
|
4922
4943
|
onWillUnmount: onWillUnmount,
|
|
4923
4944
|
onWillPatch: onWillPatch,
|
|
@@ -4931,7 +4952,7 @@ var _hooks = /*#__PURE__*/Object.freeze({
|
|
|
4931
4952
|
useExternalListener: useExternalListener
|
|
4932
4953
|
});
|
|
4933
4954
|
|
|
4934
|
-
class Store extends Context {
|
|
4955
|
+
class Store$1 extends Context$1 {
|
|
4935
4956
|
constructor(config) {
|
|
4936
4957
|
super(config.state);
|
|
4937
4958
|
this.actions = config.actions;
|
|
@@ -4970,7 +4991,7 @@ function useStore(selector, options = {}) {
|
|
|
4970
4991
|
const component = Component.current;
|
|
4971
4992
|
const componentId = component.__owl__.id;
|
|
4972
4993
|
const store = options.store || component.env.store;
|
|
4973
|
-
if (!(store instanceof Store)) {
|
|
4994
|
+
if (!(store instanceof Store$1)) {
|
|
4974
4995
|
throw new Error(`No store found when connecting '${component.constructor.name}'`);
|
|
4975
4996
|
}
|
|
4976
4997
|
let result = selector(store.state, component.props);
|
|
@@ -5517,15 +5538,15 @@ function makeExtractionRegExp(path) {
|
|
|
5517
5538
|
*
|
|
5518
5539
|
* Note that dynamic values, such as a date or a commit hash are added by rollup
|
|
5519
5540
|
*/
|
|
5520
|
-
const Context
|
|
5521
|
-
const useState
|
|
5541
|
+
const Context = Context$1;
|
|
5542
|
+
const useState = useState$1;
|
|
5522
5543
|
const core = { EventBus, Observer };
|
|
5523
5544
|
const router = { Router, RouteComponent, Link };
|
|
5524
|
-
const Store
|
|
5545
|
+
const Store = Store$1;
|
|
5525
5546
|
const utils = _utils;
|
|
5526
5547
|
const tags = _tags;
|
|
5527
5548
|
const misc = { AsyncRoot, Portal };
|
|
5528
|
-
const hooks
|
|
5549
|
+
const hooks = Object.assign({}, _hooks, {
|
|
5529
5550
|
useContext: useContext,
|
|
5530
5551
|
useDispatch: useDispatch,
|
|
5531
5552
|
useGetters: useGetters,
|
|
@@ -5534,23 +5555,23 @@ const hooks$1 = Object.assign({}, _hooks, {
|
|
|
5534
5555
|
const __info__ = {};
|
|
5535
5556
|
|
|
5536
5557
|
exports.Component = Component;
|
|
5537
|
-
exports.Context = Context
|
|
5558
|
+
exports.Context = Context;
|
|
5538
5559
|
exports.QWeb = QWeb;
|
|
5539
|
-
exports.Store = Store
|
|
5560
|
+
exports.Store = Store;
|
|
5540
5561
|
exports.__info__ = __info__;
|
|
5541
5562
|
exports.browser = browser;
|
|
5542
5563
|
exports.config = config;
|
|
5543
5564
|
exports.core = core;
|
|
5544
|
-
exports.hooks = hooks
|
|
5565
|
+
exports.hooks = hooks;
|
|
5545
5566
|
exports.misc = misc;
|
|
5546
5567
|
exports.mount = mount;
|
|
5547
5568
|
exports.router = router;
|
|
5548
5569
|
exports.tags = tags;
|
|
5549
|
-
exports.useState = useState
|
|
5570
|
+
exports.useState = useState;
|
|
5550
5571
|
exports.utils = utils;
|
|
5551
5572
|
|
|
5552
5573
|
|
|
5553
|
-
__info__.version = '1.4.
|
|
5554
|
-
__info__.date = '2021-
|
|
5555
|
-
__info__.hash = '
|
|
5574
|
+
__info__.version = '1.4.9';
|
|
5575
|
+
__info__.date = '2021-12-07T09:21:41.690Z';
|
|
5576
|
+
__info__.hash = '73f94fb';
|
|
5556
5577
|
__info__.url = 'https://github.com/odoo/owl';
|