Skip to content

Commit 71fbcbd

Browse files
committed
Merge branch 'main' into more-precise-validate-dynamic-component
2 parents 22a927c + bc9907a commit 71fbcbd

File tree

37 files changed

+307
-18
lines changed

37 files changed

+307
-18
lines changed

.changeset/clever-toys-laugh.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: hydrate multiple `<svelte:head>` elements correctly

.changeset/cold-shrimps-hug.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: assign correct scope to attributes of named slot

.changeset/fresh-zoos-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
feat: add createRawSnippet API

.changeset/pre.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
"fresh-walls-bathe",
197197
"fresh-weeks-trade",
198198
"fresh-wombats-learn",
199+
"fresh-zoos-burn",
199200
"friendly-candles-relate",
200201
"friendly-clouds-rhyme",
201202
"friendly-lies-camp",

packages/svelte/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# svelte
22

3+
## 5.0.0-next.189
4+
5+
### Patch Changes
6+
7+
- feat: add createRawSnippet API ([#12425](https://github.com/sveltejs/svelte/pull/12425))
8+
39
## 5.0.0-next.188
410

511
### Patch Changes

packages/svelte/messages/compile-errors/template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
251251
## snippet_invalid_rest_parameter
252252

253-
> snippets do not support rest parameters; use an array instead
253+
> Snippets do not support rest parameters; use an array instead
254254
255255
## snippet_shadowing_prop
256256

packages/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "svelte",
33
"description": "Cybernetically enhanced web apps",
44
"license": "MIT",
5-
"version": "5.0.0-next.188",
5+
"version": "5.0.0-next.189",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

packages/svelte/src/compiler/errors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,12 +1108,12 @@ export function snippet_conflict(node) {
11081108
}
11091109

11101110
/**
1111-
* snippets do not support rest parameters; use an array instead
1111+
* Snippets do not support rest parameters; use an array instead
11121112
* @param {null | number | NodeLike} node
11131113
* @returns {never}
11141114
*/
11151115
export function snippet_invalid_rest_parameter(node) {
1116-
e(node, "snippet_invalid_rest_parameter", "snippets do not support rest parameters; use an array instead");
1116+
e(node, "snippet_invalid_rest_parameter", "Snippets do not support rest parameters; use an array instead");
11171117
}
11181118

11191119
/**

packages/svelte/src/compiler/phases/2-analyze/validation.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,12 @@ const validation = {
674674
SnippetBlock(node, context) {
675675
validate_block_not_empty(node.body, context);
676676

677+
for (const arg of node.parameters) {
678+
if (arg.type === 'RestElement') {
679+
e.snippet_invalid_rest_parameter(arg);
680+
}
681+
}
682+
677683
context.next({ ...context.state, parent_element: null });
678684

679685
const { path } = context;

packages/svelte/src/compiler/phases/scope.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,16 +386,20 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
386386
Component(node, { state, visit, path }) {
387387
state.scope.reference(b.id(node.name), path);
388388

389-
for (const attribute of node.attributes) {
390-
visit(attribute);
391-
}
392-
393389
// let:x is super weird:
394390
// - for the default slot, its scope only applies to children that are not slots themselves
395391
// - for named slots, its scope applies to the component itself, too
396392
const [scope, is_default_slot] = analyze_let_directives(node, state.scope);
397-
if (!is_default_slot) {
393+
if (is_default_slot) {
394+
for (const attribute of node.attributes) {
395+
visit(attribute);
396+
}
397+
} else {
398398
scopes.set(node, scope);
399+
400+
for (const attribute of node.attributes) {
401+
visit(attribute, { ...state, scope });
402+
}
399403
}
400404

401405
for (const child of node.fragment.nodes) {

0 commit comments

Comments
 (0)