allow {:then}/{:catch} to have no bound identifier ()

pull/1588/head
Conduitry 7 years ago
parent 557e7b7ccb
commit b4d7653b42

@ -147,11 +147,12 @@ export default function mustache(parser: Parser) {
parser.stack.pop();
const awaitBlock = parser.current();
parser.requireWhitespace();
awaitBlock.value = parser.readIdentifier();
parser.allowWhitespace();
parser.eat('}', true);
if (!parser.eat('}')) {
parser.requireWhitespace();
awaitBlock.value = parser.readIdentifier();
parser.allowWhitespace();
parser.eat('}', true);
}
const thenBlock: Node = {
start,
@ -170,11 +171,12 @@ export default function mustache(parser: Parser) {
parser.stack.pop();
const awaitBlock = parser.current();
parser.requireWhitespace();
awaitBlock.error = parser.readIdentifier();
parser.allowWhitespace();
parser.eat('}', true);
if (!parser.eat('}')) {
parser.requireWhitespace();
awaitBlock.error = parser.readIdentifier();
parser.allowWhitespace();
parser.eat('}', true);
}
const catchBlock: Node = {
start,

@ -0,0 +1,41 @@
let fulfil;
let thePromise = new Promise(f => {
fulfil = f;
});
export default {
data: {
thePromise
},
html: `waiting`,
test(assert, component, target) {
fulfil(9000);
return thePromise
.then(() => {
assert.htmlEqual(target.innerHTML, `resolved`);
let reject;
thePromise = new Promise((f, r) => {
reject = r;
});
component.set({
thePromise
});
assert.htmlEqual(target.innerHTML, `waiting`);
reject(new Error('something broke'));
return thePromise.catch(() => {});
})
.then(() => {
assert.htmlEqual(target.innerHTML, `rejected`);
});
}
};

@ -0,0 +1,7 @@
{#await thePromise}
waiting
{:then}
resolved
{:catch}
rejected
{/await}
Loading…
Cancel
Save