aurelia
aurelia copied to clipboard
feat(syntax): Nullish coalescing op ??
Pull Request
📖 Description
Add support for ??
in the expression parser, and template. Now it's possible to do this
<el value.bind="prop1 ?? prop2">
An issue with Aurelia expression behavior is that Aurelia automatically coerces null
/undefined
to empty string in non strict mode, which won't work with ??
.
We will probably need to start thinking of adding safe navigation operator ?.
and revisit strict vs non-strict mode soon.
Thanks @fkleuver for the parser work.
@HamedFathi thanks for reminding about that issue. That probably should be added too. I'm not sure whether it should be added together with this, or a separate one. cc @fkleuver
The benchmarking comparison can be found here: https://au2-bench-viewer.azurewebsites.net/compare?branch=master&commit=13a730fabf730bd59498ad4d84fc14361fd922b3&branch=nullish-coalescing-op&commit=ea3371707d9156d9d798b2f602449ba0921b7b4f
Codecov Report
Merging #1202 (8731a6c) into master (3d468c9) will increase coverage by
0.01%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## master #1202 +/- ##
==========================================
+ Coverage 87.94% 87.95% +0.01%
==========================================
Files 159 159
Lines 17224 17241 +17
Branches 3588 3598 +10
==========================================
+ Hits 15147 15164 +17
Misses 2077 2077
Impacted Files | Coverage Δ | |
---|---|---|
packages/runtime/src/binding/ast.ts | 76.61% <100.00%> (+0.05%) |
:arrow_up: |
packages/runtime/src/binding/expression-parser.ts | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 3d468c9...8731a6c. Read the comment docs.
I'm not sure whether it should be added together with this, or a separate one.
Doesn't matter, there's no breaking changes or conflicts etc either way. I can't predict very well when I'll have time though at the moment.
are these things not going to make it into v2?
are these things not going to make it into v2?
@milkshakeuk null
/undefined
are often treated as an empty string, hence the mention of strict vs non strict mode (default). Applications normally prefer non strict mode I'd assume, so while it could be useful, it's not a lot more meaningful yet. Though eventually this and ?.
should be in.