Skip to content

Commit

Permalink
(feat) support for svelte:fragment (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm authored Mar 2, 2021
1 parent 800b2cd commit 0ea7095
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# prettier-plugin-svelte changelog

## 2.2.0 (Unreleased)

* Add support for `svelte:fragment` ([#213](https://github.com/sveltejs/prettier-plugin-svelte/pull/213))

## 2.1.6

* Fix incorrect removal of comment ([#207](https://github.com/sveltejs/prettier-plugin-svelte/issues/207))
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@rollup/plugin-commonjs": "14.0.0",
"@rollup/plugin-node-resolve": "11.0.1",
"rollup-plugin-typescript": "1.0.1",
"svelte": "^3.30.0",
"svelte": "^3.35.0",
"ts-node": "^9.1.1",
"tslib": "^2.0.3",
"typescript": "4.1.3"
Expand Down
1 change: 1 addition & 0 deletions src/print/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
case 'Element':
case 'InlineComponent':
case 'Slot':
case 'SlotTemplate':
case 'Window':
case 'Head':
case 'Title': {
Expand Down
9 changes: 8 additions & 1 deletion src/print/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ export interface OptionsNode extends BaseNode {
attributes: Node[];
}

export interface SlotTemplateNode extends BaseNode {
type: 'SlotTemplate';
name: string;
attributes: Node[];
}

export type Node =
| FragmentNode
| ElementNode
Expand Down Expand Up @@ -293,7 +299,8 @@ export type Node =
| InstanceScriptNode
| ModuleScriptNode
| BodyNode
| OptionsNode;
| OptionsNode
| SlotTemplateNode;

/**
* The Svelte AST root node
Expand Down
5 changes: 5 additions & 0 deletions test/printer/samples/svelte-fragment-element.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<svelte:fragment />
<svelte:fragment slot="named" let:foo>
<p>hi</p>
</svelte:fragment>
<svelte:fragment slot="named" let:foo><p>hi</p></svelte:fragment>

0 comments on commit 0ea7095

Please sign in to comment.