Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destructuring #1385

Merged
merged 4 commits into from
Apr 29, 2018
Merged

Destructuring #1385

merged 4 commits into from
Apr 29, 2018

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Apr 29, 2018

This updates the existing destructuredContexts mechanism to support arbitrary destructuring forms, so that you can do this sort of thing:

{#each things as { x: [y, z] } }
  <p>{z}</p>
{/each}

More realistically, you could use it for simple object pattern destructuring, but I didn't see any reason to arbitrarily restrict the patterns you could use. For now it doesn't support assignment patterns — we'll see if those turn out to be necessary. (They're a little finicky to parse.)

TODO

  • sparse array patterns
  • two-way binding

@codecov-io
Copy link

codecov-io commented Apr 29, 2018

Codecov Report

Merging #1385 into master will increase coverage by 0.02%.
The diff coverage is 92.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1385      +/-   ##
==========================================
+ Coverage   91.21%   91.24%   +0.02%     
==========================================
  Files         120      122       +2     
  Lines        4429     4454      +25     
  Branches     1362     1367       +5     
==========================================
+ Hits         4040     4064      +24     
- Misses        154      156       +2     
+ Partials      235      234       -1
Impacted Files Coverage Δ
src/compile/nodes/Fragment.ts 100% <ø> (ø) ⬆️
src/compile/dom/Block.ts 95.78% <100%> (-0.05%) ⬇️
src/parse/state/mustache.ts 88.88% <100%> (+0.91%) ⬆️
src/validate/html/index.ts 97.91% <100%> (-0.05%) ⬇️
src/compile/nodes/EachBlock.ts 98.65% <100%> (+0.61%) ⬆️
src/compile/nodes/Binding.ts 96% <100%> (-0.04%) ⬇️
src/compile/nodes/Component.ts 95.65% <100%> (-0.02%) ⬇️
src/utils/unpackDestructuring.ts 88.88% <88.88%> (ø)
src/parse/read/context.ts 89.47% <89.47%> (ø)
... and 1 more

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 dbd5a76...70034ea. Read the comment docs.

@Rich-Harris Rich-Harris changed the title [WIP] Destructuring Destructuring Apr 29, 2018
@Rich-Harris Rich-Harris merged commit 1130556 into master Apr 29, 2018
@Rich-Harris Rich-Harris deleted the destructuring branch April 29, 2018 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants