diff --git a/src/cli/index.ts b/src/cli/index.ts index 1ceb8e9bc1..ca0ed51caa 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -17,6 +17,7 @@ prog .option('--no-css', `Don't include CSS (useful with SSR)`) .option('--immutable', 'Support immutable data structures') .option('--shared', 'Don\'t include shared helpers') + .option('--customElement', 'Generate a custom element') .example('compile App.html > App.js') .example('compile src -o dest') diff --git a/src/compile/render-dom/wrappers/AwaitBlock.ts b/src/compile/render-dom/wrappers/AwaitBlock.ts index 4ddecfc771..c0b719f140 100644 --- a/src/compile/render-dom/wrappers/AwaitBlock.ts +++ b/src/compile/render-dom/wrappers/AwaitBlock.ts @@ -174,6 +174,7 @@ export default class AwaitBlockWrapper extends Wrapper { block.builders.mount.addBlock(deindent` ${info}.block.${hasTransitions ? 'i' : 'm'}(${initialMountNode}, ${info}.anchor = ${anchorNode}); ${info}.mount = () => ${updateMountNode}; + ${info}.anchor = ${anchor}; `); const conditions = []; diff --git a/src/internal/dom.js b/src/internal/dom.js index e12102d3ca..32c06dc159 100644 --- a/src/internal/dom.js +++ b/src/internal/dom.js @@ -112,10 +112,8 @@ export function setAttributes(node, attributes) { export function setCustomElementData(node, prop, value) { if (prop in node) { node[prop] = value; - } else if (value) { - setAttribute(node, prop, value); } else { - node.removeAttribute(prop); + setAttribute(node, prop, value); } } diff --git a/test/helpers.js b/test/helpers.js index 25a7491b30..53b62aca5a 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -48,6 +48,8 @@ export function tryToReadFile(file) { export const virtualConsole = new jsdom.VirtualConsole(); const { window } = new jsdom.JSDOM('', {virtualConsole}); global.document = window.document; +global.getComputedStyle = window.getComputedStyle; +global.navigator = {userAgent: 'fake'}; export function env() { window._svelteTransitionManager = null; diff --git a/test/runtime/samples/await-then-catch-order/_config.js b/test/runtime/samples/await-then-catch-order/_config.js new file mode 100644 index 0000000000..5c4eb530e9 --- /dev/null +++ b/test/runtime/samples/await-then-catch-order/_config.js @@ -0,0 +1,27 @@ +let fulfil; + +let thePromise = new Promise(f => { + fulfil = f; +}); + +export default { + props: { + thePromise + }, + + html: ` +
loading...
true!
+ `, + + test({ assert, component, target }) { + fulfil(42); + + return thePromise + .then(() => { + assert.htmlEqual(target.innerHTML, ` +the value is 42
true!
+ `); + }); + + } +}; diff --git a/test/runtime/samples/await-then-catch-order/main.html b/test/runtime/samples/await-then-catch-order/main.html new file mode 100644 index 0000000000..87b37bf27d --- /dev/null +++ b/test/runtime/samples/await-then-catch-order/main.html @@ -0,0 +1,11 @@ +{#await thePromise} +loading...
+{:then theValue} +the value is {theValue}
+{:catch theError} +oh no! {theError.message}
+{/await} + +{#if true} +true!
+{/if} diff --git a/test/runtime/samples/transition-js-await-block/_config.js b/test/runtime/samples/transition-js-await-block/_config.js index 20f29cebd3..5cddc8a95c 100644 --- a/test/runtime/samples/transition-js-await-block/_config.js +++ b/test/runtime/samples/transition-js-await-block/_config.js @@ -27,10 +27,10 @@ export default { return promise.then(() => { raf.tick(80); let ps = document.querySelectorAll('p'); - assert.equal(ps[0].className, 'pending'); - assert.equal(ps[1].className, 'then'); - assert.equal(ps[0].foo, 0.2); - assert.equal(ps[1].foo, 0.3); + assert.equal(ps[1].className, 'pending'); + assert.equal(ps[0].className, 'then'); + assert.equal(ps[1].foo, 0.2); + assert.equal(ps[0].foo, 0.3); }); } };