Skip to content

Commit 0cc9dbd

Browse files
feat: cte perf (#5528)
1 parent 9223fc6 commit 0cc9dbd

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

packages/@lwc/perf-benchmarks-components/src/benchmark/expression/expression.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,33 @@
55
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
66
-->
77
<template>
8+
<!-- Basic expressions (already working) -->
89
<div data-foo="{expr1()}"></div>
910
<p class="{expr2.expr21.expr22}"></p>
1011
<p>{expr3[0]['expr3' + '3']}</p>
12+
13+
<!-- Complex expressions that require experimentalComplexExpressions -->
14+
<div class="{`complex-${expr1()}-${expr2.expr21.expr22}`}">
15+
{`Template literal: ${expr1()} and ${expr2.expr21.expr22}`}
16+
</div>
17+
18+
<p data-computed="{expr1() ? 'truthy' : 'falsy'}">
19+
{expr1() ? 'Conditional: ' + expr1() : 'Default value'}
20+
</p>
21+
22+
<div class="{expr2?.expr21?.expr22 || 'fallback'}">
23+
{expr2?.expr21?.expr22 ?? 'nullish fallback'}
24+
</div>
25+
26+
<p data-array="{expr3.map(item => item.expr33).join(', ')}">
27+
{expr3.length > 0 ? `Array length: ${expr3.length}` : 'Empty array'}
28+
</p>
29+
30+
<div class="{expr1() === 'bar' ? 'matched' : 'not-matched'}">
31+
{expr1() === 'bar' ? 'String comparison works!' : 'String comparison failed'}
32+
</div>
33+
34+
<p data-object="{JSON.stringify({nested: expr2, computed: expr1()})}">
35+
{`Object: ${JSON.stringify({nested: expr2, computed: expr1()})}`}
36+
</p>
1137
</template>

packages/@lwc/perf-benchmarks-components/src/benchmark/expression/expression.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,27 @@ export default class Sample extends LightningElement {
1313

1414
expr2 = { expr21: { expr22: 'expr22' } };
1515
expr3 = [{ expr33: 'expr33' }];
16+
17+
// Additional data for complex expression testing
18+
get complexData() {
19+
return {
20+
string: 'test',
21+
number: 42,
22+
boolean: true,
23+
array: [1, 2, 3, 4, 5],
24+
nested: {
25+
deep: {
26+
value: 'nested value',
27+
},
28+
},
29+
};
30+
}
31+
32+
get computedValue() {
33+
return this.expr1() + '_computed';
34+
}
35+
36+
get conditionalValue() {
37+
return this.expr2?.expr21?.expr22 ? 'hasValue' : 'noValue';
38+
}
1639
}

0 commit comments

Comments
 (0)