diff --git a/CHANGELOG.md b/CHANGELOG.md index ce92114b0b..3419e6da1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## 2.15.1 + +* Don't throw missing store error when store is declared in component ([#1828](https://github.com/sveltejs/svelte/issues/1828)) + ## 2.15.0 * Event modifiers ([#1088](https://github.com/sveltejs/svelte/issues/1088)) diff --git a/package-lock.json b/package-lock.json index 2bb4b96513..f2cb89889d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "2.14.2", + "version": "2.15.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 64a975773d..346bd0f6fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "2.15.0", + "version": "2.15.1", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "bin": { 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/helpers.js b/test/helpers.js index 7a04ff0262..7b1f08bb45 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/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 diff --git a/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/_config.js b/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/_config.js new file mode 100644 index 0000000000..ff2b87b712 --- /dev/null +++ b/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/_config.js @@ -0,0 +1,8 @@ +export default { + 'skip-ssr': true, + + test(assert, component, target) { + assert.ok(component.onstateRanBeforeOncreate); + assert.ok(!component.onupdateRanBeforeOncreate); + } +}; diff --git a/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/main.html b/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/main.html new file mode 100644 index 0000000000..d930bbcbbb --- /dev/null +++ b/test/runtime/samples/onupdate-after-concreate-using-bind-offsetWidth/main.html @@ -0,0 +1,17 @@ + +