From cb4a46d33ff4d73c80e132b61dee9e8927bfdf48 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Tue, 30 Oct 2018 10:32:12 -0700 Subject: [PATCH] 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 --- src/compile/render-dom/index.ts | 2 +- src/compile/render-ssr/index.ts | 2 +- .../samples/dev-accept-declarative-store/_config.js | 5 +++++ .../samples/dev-accept-declarative-store/main.html | 11 +++++++++++ .../_config.js | 0 .../main.html | 0 6 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 test/runtime/samples/dev-accept-declarative-store/_config.js create mode 100644 test/runtime/samples/dev-accept-declarative-store/main.html rename test/runtime/samples/{dev-error-missing-store => dev-error-missing-store-option}/_config.js (100%) rename test/runtime/samples/{dev-error-missing-store => dev-error-missing-store-option}/main.html (100%) diff --git a/src/compile/render-dom/index.ts b/src/compile/render-dom/index.ts index a84f8fefa6..039f901731 100644 --- a/src/compile/render-dom/index.ts +++ b/src/compile/render-dom/index.ts @@ -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"); }`} diff --git a/src/compile/render-ssr/index.ts b/src/compile/render-ssr/index.ts index a424b5c2ea..8edc101910 100644 --- a/src/compile/render-ssr/index.ts +++ b/src/compile/render-ssr/index.ts @@ -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"); } diff --git a/test/runtime/samples/dev-accept-declarative-store/_config.js b/test/runtime/samples/dev-accept-declarative-store/_config.js new file mode 100644 index 0000000000..5b9d5ecf1a --- /dev/null +++ b/test/runtime/samples/dev-accept-declarative-store/_config.js @@ -0,0 +1,5 @@ +export default { + compileOptions: { + dev: true + } +}; diff --git a/test/runtime/samples/dev-accept-declarative-store/main.html b/test/runtime/samples/dev-accept-declarative-store/main.html new file mode 100644 index 0000000000..a20bbf0d65 --- /dev/null +++ b/test/runtime/samples/dev-accept-declarative-store/main.html @@ -0,0 +1,11 @@ +

{$foo}

+ + diff --git a/test/runtime/samples/dev-error-missing-store/_config.js b/test/runtime/samples/dev-error-missing-store-option/_config.js similarity index 100% rename from test/runtime/samples/dev-error-missing-store/_config.js rename to test/runtime/samples/dev-error-missing-store-option/_config.js diff --git a/test/runtime/samples/dev-error-missing-store/main.html b/test/runtime/samples/dev-error-missing-store-option/main.html similarity index 100% rename from test/runtime/samples/dev-error-missing-store/main.html rename to test/runtime/samples/dev-error-missing-store-option/main.html