Skip to content

Commit 4d49839

Browse files
committed
Merge branch 'test-sveltejsgh-1743' into sveltejsgh-1743
2 parents d27dbae + fd9dc30 commit 4d49839

File tree

12 files changed

+51
-4
lines changed

12 files changed

+51
-4
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Svelte changelog
22

3+
## 2.15.1
4+
5+
* Don't throw missing store error when store is declared in component ([#1828](https://github.com/sveltejs/svelte/issues/1828))
6+
37
## 2.15.0
48

59
* Event modifiers ([#1088](https://github.com/sveltejs/svelte/issues/1088))

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte",
3-
"version": "2.15.0",
3+
"version": "2.15.1",
44
"description": "The magical disappearing UI framework",
55
"main": "compiler/svelte.js",
66
"bin": {

src/compile/render-dom/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export default function dom(
152152
if (!options || (!options.target && !options.root)) {
153153
throw new Error("'target' is a required option");
154154
}`}
155-
${storeProps.length > 0 && deindent`
155+
${storeProps.length > 0 && !templateProperties.store && deindent`
156156
if (!options.store) {
157157
throw new Error("${debugName} references store properties, but no store was provided");
158158
}`}

src/compile/render-ssr/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default function ssr(
115115
${templateProperties.store && `options.store = %store();`}
116116
__result.addComponent(${name});
117117
118-
${options.dev && storeProps.length > 0 && deindent`
118+
${options.dev && storeProps.length > 0 && !templateProperties.store && deindent`
119119
if (!options.store) {
120120
throw new Error("${debugName} references store properties, but no store was provided");
121121
}

test/helpers.js

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export function tryToReadFile(file) {
4848
export const virtualConsole = new jsdom.VirtualConsole();
4949
const { window } = new jsdom.JSDOM('<main></main>', {virtualConsole});
5050
global.document = window.document;
51+
global.getComputedStyle = window.getComputedStyle;
52+
global.navigator = {userAgent: 'fake'};
5153

5254
export function env() {
5355
window._svelteTransitionManager = null;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
compileOptions: {
3+
dev: true
4+
}
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<p>{$foo}</p>
2+
3+
<script>
4+
import { Store } from '../../../../store.js';
5+
6+
const store = new Store({ foo : "foo" });
7+
8+
export default {
9+
store : () => store,
10+
};
11+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
'skip-ssr': true,
3+
4+
test(assert, component, target) {
5+
assert.ok(component.onstateRanBeforeOncreate);
6+
assert.ok(!component.onupdateRanBeforeOncreate);
7+
}
8+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div bind:offsetWidth=width></div>
2+
<script>
3+
export default {
4+
onstate() {
5+
this.onstateRan = true;
6+
},
7+
8+
onupdate() {
9+
this.onupdateRan = true;
10+
},
11+
12+
oncreate() {
13+
this.onstateRanBeforeOncreate = this.onstateRan;
14+
this.onupdateRanBeforeOncreate = this.onupdateRan;
15+
}
16+
};
17+
</script>

0 commit comments

Comments
 (0)