leanweb 1.3.1 → 1.3.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/package.json
CHANGED
|
@@ -200,6 +200,8 @@ export default class LWElement extends HTMLElement {
|
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
// properties:
|
|
204
|
+
// lw_input_bound: boolean
|
|
203
205
|
_bindInputs(inputNode) {
|
|
204
206
|
if (inputNode['lw_input_bound']) {
|
|
205
207
|
return;
|
|
@@ -237,14 +239,15 @@ export default class LWElement extends HTMLElement {
|
|
|
237
239
|
const context = this._getNodeContext(eventNode);
|
|
238
240
|
const eventContext = { '$event': event, '$node': eventNode };
|
|
239
241
|
const parsed = parser.evaluate(interpolation.ast, [eventContext, ...context], interpolation.loc);
|
|
240
|
-
|
|
241
|
-
const promises = parsed.filter(p => typeof p?.then === 'function');
|
|
242
|
+
const promises = parsed.filter(p => typeof p?.then === 'function' && typeof p?.finally === 'function');
|
|
242
243
|
if (parsed.length > promises.length) {
|
|
243
244
|
me.update();
|
|
244
245
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
promises.forEach(p => {
|
|
247
|
+
p?.finally(() => {
|
|
248
|
+
me.update();
|
|
249
|
+
});
|
|
250
|
+
});
|
|
248
251
|
}).bind(me));
|
|
249
252
|
});
|
|
250
253
|
}
|
|
@@ -24,6 +24,25 @@ const binaryOperations = {
|
|
|
24
24
|
// '|>': (a, b) => a |> b,
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
const assignmentOperations = {
|
|
28
|
+
'=': (c, a, b) => { c[a] = b; },
|
|
29
|
+
'+=': (c, a, b) => { c[a] += b; },
|
|
30
|
+
'-=': (c, a, b) => { c[a] -= b; },
|
|
31
|
+
'*=': (c, a, b) => { c[a] *= b; },
|
|
32
|
+
'/=': (c, a, b) => { c[a] /= b; },
|
|
33
|
+
'%=': (c, a, b) => { c[a] %= b; },
|
|
34
|
+
'**=': (c, a, b) => { c[a] **= b; },
|
|
35
|
+
'&&=': (c, a, b) => { c[a] &&= b; },
|
|
36
|
+
'??=': (c, a, b) => { c[a] ??= b; },
|
|
37
|
+
'||=': (c, a, b) => { c[a] ||= b; },
|
|
38
|
+
'>>=': (c, a, b) => { c[a] >>= b; },
|
|
39
|
+
'>>>=': (c, a, b) => { c[a] >>>= b; },
|
|
40
|
+
'<<=': (c, a, b) => { c[a] <<= b; },
|
|
41
|
+
'&=': (c, a, b) => { c[a] &= b; },
|
|
42
|
+
'|=': (c, a, b) => { c[a] |= b; },
|
|
43
|
+
'^=': (c, a, b) => { c[a] ^= b; },
|
|
44
|
+
};
|
|
45
|
+
|
|
27
46
|
const logicalOperators = {
|
|
28
47
|
'||': (a, b) => a || b,
|
|
29
48
|
'&&': (a, b) => a && b,
|
|
@@ -43,9 +62,9 @@ const unaryOperators = {
|
|
|
43
62
|
|
|
44
63
|
const updateOperators = (operator, prefix) => {
|
|
45
64
|
if (operator === '++') {
|
|
46
|
-
return
|
|
65
|
+
return (c, a) => prefix ? ++c[a] : c[a]++;
|
|
47
66
|
} else if (operator === '--') {
|
|
48
|
-
return
|
|
67
|
+
return (c, a) => prefix ? --c[a] : c[a]--;
|
|
49
68
|
}
|
|
50
69
|
};
|
|
51
70
|
|
|
@@ -75,9 +94,16 @@ const nodeHandlers = {
|
|
|
75
94
|
|
|
76
95
|
'ExpressionStatement': (node, context) => evalNode(node.expression, context),
|
|
77
96
|
'BinaryExpression': (node, context) => binaryOperations[node.operator](evalNode(node.left, context), evalNode(node.right, context)),
|
|
97
|
+
'AssignmentExpression': (node, context) => {
|
|
98
|
+
const immediateCtx = immediateContext(node.left, context);
|
|
99
|
+
assignmentOperations[node.operator](immediateCtx, node.left.name, evalNode(node.right, context));
|
|
100
|
+
},
|
|
78
101
|
'LogicalExpression': (node, context) => logicalOperators[node.operator](evalNode(node.left, context), evalNode(node.right, context)),
|
|
79
102
|
'UnaryExpression': (node, context) => unaryOperators[node.operator](evalNode(node.argument, context)),
|
|
80
|
-
'UpdateExpression': (node, context) =>
|
|
103
|
+
'UpdateExpression': (node, context) => {
|
|
104
|
+
const immediateCtx = immediateContext(node.argument, context);
|
|
105
|
+
updateOperators(node.operator, node.prefix)(immediateCtx, node.argument.name, evalNode(node.argument, context));
|
|
106
|
+
},
|
|
81
107
|
'ConditionalExpression': (node, context) => {
|
|
82
108
|
const test = evalNode(node.test, context);
|
|
83
109
|
const consequent = evalNode(node.consequent, context);
|
|
@@ -144,6 +170,14 @@ const nodeHandlers = {
|
|
|
144
170
|
'DirectiveLiteral': (node, context) => node.value,
|
|
145
171
|
};
|
|
146
172
|
|
|
173
|
+
const immediateContext = (node, context) => {
|
|
174
|
+
if (Array.isArray(context)) {
|
|
175
|
+
return context.find(contextObj => node.name in contextObj);
|
|
176
|
+
} else if (typeof context === 'object') {
|
|
177
|
+
return context;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
147
181
|
const evalNode = (node, context) => nodeHandlers[node.type](node, context);
|
|
148
182
|
|
|
149
183
|
const evaluate = (ast, context = {}, loc = {}) => {
|