Skip to content

Commit a860db7

Browse files
committed
fix references to children prop
1 parent 60dfe7d commit a860db7

File tree

8 files changed

+12
-13
lines changed

8 files changed

+12
-13
lines changed

examples/Templating.stories.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<script>
1818
/**
1919
* call setTemplate with a reference to any root-level snippet, for that snippet to be the fallback snippet,
20-
* that is used in any story without explicit children.
20+
* that is used in any story without explicit template.
2121
*/
2222
setTemplate(defaultTemplate);
2323
</script>
@@ -130,7 +130,7 @@
130130

131131
<!--
132132
To set a default template for all stories in the file, call the **`setTemplate()`** function with a reference to a root snippet.
133-
Any story without `children` will use this default template.
133+
Any story without `template` will use this default template.
134134
135135
Example:
136136

src/compiler/pre-transform/codemods/legacy-story.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function transformLegacyStory(params: Params): SvelteAST.Component {
7575
if (fragment.nodes.length === 0 && !hasTemplateAttribute && state.unidentifiedTemplateComponent) {
7676
newAttributes.push(
7777
createASTAttribute(
78-
'children',
78+
'template',
7979
createASTExpressionTag({
8080
type: 'Identifier',
8181
name: 'sb_default_template',

src/parser/extract/svelte/fragment-nodes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe(extractFragmentNodes.name, () => {
102102
<Story name="Example1" />
103103
104104
<Story name="Example2">
105-
{#snippet children(args)}
105+
{#snippet template(args)}
106106
<SampleComponent {...args} />
107107
{/snippet}
108108
</Story>

src/parser/extract/svelte/fragment-nodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface Result {
1818
* For example:
1919
* Determining the source code of the `<Story />`.
2020
* Based on either `setTemplate` call,
21-
* or by passing `children` as prop from the outer Svelte snippet block definition - e.g. `Story children={template1} />`.
21+
* or by passing `template` as prop from the outer Svelte snippet block definition - e.g. `Story template={template1} />`.
2222
*/
2323
snippetBlocks: SvelteAST.SnippetBlock[];
2424
}

src/parser/extract/svelte/nodes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe(extractSvelteASTNodes.name, () => {
2121
<Story name="Default" />
2222
2323
<Story name="Playground">
24-
{#snippet children(args)}
24+
{#snippet template(args)}
2525
<Button {...args} />
2626
{/snippet}
2727
</Story>

src/runtime/Story.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@
7272
(
7373
| {
7474
/**
75-
* The content to render in the story as **static** markup.
76-
*
77-
* NOTE: Can be omitted if a default template is set with [`setTemplate()`](https://github.com/storybookjs/addon-svelte-csf/blob/main/README.md#default-snippet)
75+
* Children to pass to the story's component
76+
* Or if `asChild` is true, the content to render in the story as **static** markup.
7877
*/
7978
children?: TChildren;
8079
/**

src/utils/error/parser/extract/svelte.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,17 @@ export class InvalidStoryTemplateAttributeError extends StorybookSvelteCSFError
172172
template() {
173173
return dedent`
174174
Component '${this.quickStoryRawCodeIdentifier}' in the stories file '${this.filepathURL}'
175-
has an invalid 'children'-prop.
175+
has an invalid 'template'-prop.
176176
177-
When set, the 'children'-prop must be an expression with reference to a root-level snippet.
177+
When set, the 'template'-prop must be an expression with reference to a root-level snippet.
178178
179179
Eg.:
180180
181181
{#snippet template()}
182182
...
183183
{/snippet}
184184
185-
<Story name="${this.storyNameFromAttribute}" children={template} />
185+
<Story name="${this.storyNameFromAttribute}" template={template} />
186186
`;
187187
}
188188
}

tests/stories/test/StoryContext.stories.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</script>
2121

2222
<Story name="Default">
23-
{#snippet children(_args, context)}
23+
{#snippet template(_args, context)}
2424
<pre>
2525
<code>
2626
{JSON.stringify(context, replacer, 2)}

0 commit comments

Comments
 (0)