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
pull/1836/head
Pat Cavit 6 years ago committed by Conduitry
parent 03c7612c6b
commit cb4a46d33f

@ -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");
}`}

@ -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");
}

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

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