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:
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
|
||||
}
|
||||
};
|
11
test/runtime/samples/dev-accept-declarative-store/main.html
Normal file
11
test/runtime/samples/dev-accept-declarative-store/main.html
Normal 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>
|
Loading…
Reference in New Issue
Block a user