Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing a store to nested components on server side #1116

Merged
merged 2 commits into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/generators/server-side-rendering/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export default function ssr(
}

var result = { head: '', addComponent };
${templateProperties.store && `options.store = %store();`}
var html = ${name}._render(result, state, options);

var cssCode = Array.from(components).map(c => c.css && c.css.code).filter(Boolean).join('\\n');
Expand All @@ -130,6 +129,7 @@ export default function ssr(
}

${name}._render = function(__result, state, options) {
${templateProperties.store && `options.store = %store();`}
__result.addComponent(${name});

state = Object.assign(${initialState.join(', ')});
Expand Down
13 changes: 13 additions & 0 deletions test/runtime/samples/store-nested/Nested.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h1>Hello, {{$name}}!</h1>

<script>
import { Store } from '../../../../store.js';

export default {
store () {
return new Store({
name: 'world'
});
},
};
</script>
7 changes: 7 additions & 0 deletions test/runtime/samples/store-nested/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
store: true, // TODO remove this in v2

html: `
<h1>Hello, world!</h1>
`,
};
11 changes: 11 additions & 0 deletions test/runtime/samples/store-nested/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Nested/>

<script>
import Nested from './Nested.html';

export default {
components: {
Nested
}
};
</script>