0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

fix: add check for template store to conditional (#1829)

* fix: add check for template store to conditional

* fix: move store check to generation

Per @Conduitry's request

* test: add test to ensure declative store works

* test: rename to better match functionality
This commit is contained in:
Pat Cavit 2018-10-30 10:32:12 -07:00 committed by Conduitry
parent 03c7612c6b
commit cb4a46d33f
6 changed files with 18 additions and 2 deletions

View File

@ -152,7 +152,7 @@ export default function dom(
if (!options || (!options.target && !options.root)) {
throw new Error("'target' is a required option");
}`}
${storeProps.length > 0 && deindent`
${storeProps.length > 0 && !templateProperties.store && deindent`
if (!options.store) {
throw new Error("${debugName} references store properties, but no store was provided");
}`}

View File

@ -115,7 +115,7 @@ export default function ssr(
${templateProperties.store && `options.store = %store();`}
__result.addComponent(${name});
${options.dev && storeProps.length > 0 && deindent`
${options.dev && storeProps.length > 0 && !templateProperties.store && deindent`
if (!options.store) {
throw new Error("${debugName} references store properties, but no store was provided");
}

View File

@ -0,0 +1,5 @@
export default {
compileOptions: {
dev: true
}
};

View File

@ -0,0 +1,11 @@
<p>{$foo}</p>
<script>
import { Store } from '../../../../store.js';
const store = new Store({ foo : "foo" });
export default {
store : () => store,
};
</script>