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

await-then-catch #952

Merged
merged 10 commits into from
Dec 3, 2017
Merged

await-then-catch #952

merged 10 commits into from
Dec 3, 2017

Conversation

Rich-Harris
Copy link
Member

Ref #654. So far, this just teaches the parser how to deal with {{#await ...}} and friends.

@codecov-io
Copy link

codecov-io commented Nov 25, 2017

Codecov Report

Merging #952 into master will increase coverage by 0.05%.
The diff coverage is 91.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #952      +/-   ##
==========================================
+ Coverage   91.78%   91.84%   +0.05%     
==========================================
  Files         110      112       +2     
  Lines        3980     4107     +127     
  Branches     1304     1332      +28     
==========================================
+ Hits         3653     3772     +119     
- Misses        142      143       +1     
- Partials      185      192       +7
Impacted Files Coverage Δ
...generators/server-side-rendering/visitors/index.ts 100% <ø> (ø) ⬆️
test/parser/index.js 100% <ø> (ø) ⬆️
src/generators/dom/visitors/index.ts 100% <ø> (ø) ⬆️
src/generators/server-side-rendering/preprocess.ts 100% <100%> (ø) ⬆️
src/generators/dom/preprocess.ts 97.68% <100%> (+0.23%) ⬆️
...ators/server-side-rendering/visitors/AwaitBlock.ts 100% <100%> (ø)
src/parse/index.ts 89.28% <100%> (+0.82%) ⬆️
src/generators/Generator.ts 94.03% <100%> (+0.1%) ⬆️
src/generators/server-side-rendering/index.ts 98.07% <100%> (+0.07%) ⬆️
src/parse/state/mustache.ts 88.88% <86.36%> (+0.98%) ⬆️
... and 3 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 fd77c40...844e89f. Read the comment docs.

@Rich-Harris Rich-Harris changed the title [WIP] await-then-catch await-then-catch Nov 25, 2017
@Rich-Harris
Copy link
Member Author

I think this is just about ready, if anyone is curious to take a look. There's room for improvements — some opportunities for DRYing out, etc — but the functionality is there.

Not covered in this PR:

  • await once
  • transitions (would be nice to e.g. fade from loading to rendered states)
  • {{#await promise then value}} shorthand
  • async/streaming SSR renderer

@aubergene
Copy link

aubergene commented Dec 1, 2017

Tried to read the code, but I don't know the innards of Svelte well enough. I'm using this branch and it works as expected and is super helpful! Merge ASAP :)

Edit: I found I got these errors when trying to use two await blocks within the same component

shared.js:21 Uncaught DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
    at insertNode (http://localhost:3000/public/js/test.js:26:9)
    at Object.mount [as m] (http://localhost:3000/public/js/test.js:399:4)
    at Object.mount [as m] (http://localhost:3000/public/js/test.js:337:18)
    at new Test (http://localhost:3000/public/js/test.js:573:18)
    at http://localhost:3000/public/test.html:18:14
insertNode @ shared.js:21
mount @ Test.html:14
mount @ Test.html:4
Test @ Test.html:19
(anonymous) @ test.html:18
Test.html:32 GET http://localhost:3000/now/ 404 (Not Found)
nowFetch @ Test.html:32
_recompute @ Test.html:19
Test @ Test.html:19
(anonymous) @ test.html:18
Test.html:33 GET http://localhost:3000/every10/ 404 (Not Found)
every10Fetch @ Test.html:33
_recompute @ Test.html:19
Test @ Test.html:19
(anonymous) @ test.html:18
shared.js:25 Uncaught (in promise) TypeError: Cannot read property 'removeChild' of null
    at detachNode (shared.js:25)
    at Object.unmount [as u] (Test.html:11)
    at replace_await_block_1 (Test.html:6)
    at Test.html:6
    at <anonymous>

@Rich-Harris Rich-Harris merged commit 7e40ee2 into master Dec 3, 2017
@Rich-Harris Rich-Harris deleted the gh-654 branch December 3, 2017 14:46
@Rich-Harris
Copy link
Member Author

Good catch, thanks — it was using the wrong variable to use when mounting, which meant it tried to attach itself to a not-yet-existent DOM node

@aubergene aubergene mentioned this pull request Dec 3, 2017
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

3 participants