Skip to content

Commit 6d03800

Browse files
committed
Merge branch 'main' into bump-dts-buddy
2 parents b6ff839 + 8ae5885 commit 6d03800

File tree

18 files changed

+112
-487
lines changed

18 files changed

+112
-487
lines changed

.changeset/polite-ways-serve.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: throw compilation error for malformed snippets

.changeset/pre.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@
543543
"swift-feet-juggle",
544544
"swift-knives-tie",
545545
"swift-poets-carry",
546+
"swift-rats-sing",
546547
"swift-ravens-hunt",
547548
"swift-seahorses-deliver",
548549
"tall-books-grin",
@@ -559,6 +560,7 @@
559560
"tasty-steaks-smile",
560561
"ten-eels-move",
561562
"ten-foxes-repeat",
563+
"ten-geese-share",
562564
"ten-jokes-divide",
563565
"ten-peaches-sleep",
564566
"ten-singers-cough",

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
3535
"@types/node": "^20.11.5",
3636
"@vitest/coverage-v8": "^1.2.1",
37-
"concurrently": "^8.2.2",
38-
"cross-env": "^7.0.3",
3937
"eslint": "^9.0.0",
4038
"eslint-plugin-lube": "^0.4.3",
4139
"jsdom": "22.0.0",

packages/svelte/CHANGELOG.md

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

3+
## 5.0.0-next.164
4+
5+
### Patch Changes
6+
7+
- fix: prevent `a11y_label_has_associated_control` false positive for component or render tag in `<label>` ([#12119](https://github.com/sveltejs/svelte/pull/12119))
8+
9+
- fix: allow multiple optional parameters with defaults in snippets ([#12070](https://github.com/sveltejs/svelte/pull/12070))
10+
311
## 5.0.0-next.163
412

513
### Patch Changes

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.163",
5+
"version": "5.0.0-next.164",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

packages/svelte/src/compiler/phases/1-parse/read/context.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ import { locator } from '../../../state.js';
1414

1515
/**
1616
* @param {import('../index.js').Parser} parser
17-
* @param {boolean} [optional_allowed]
1817
* @returns {import('estree').Pattern}
1918
*/
20-
export default function read_pattern(parser, optional_allowed = false) {
19+
export default function read_pattern(parser) {
2120
const start = parser.index;
2221
let i = parser.index;
2322

2423
const code = full_char_code_at(parser.template, i);
2524
if (isIdentifierStart(code, true)) {
2625
const name = /** @type {string} */ (parser.read_identifier());
27-
const annotation = read_type_annotation(parser, optional_allowed);
26+
const annotation = read_type_annotation(parser);
2827

2928
return {
3029
type: 'Identifier',
@@ -84,7 +83,7 @@ export default function read_pattern(parser, optional_allowed = false) {
8483
parse_expression_at(`${space_with_newline}(${pattern_string} = 1)`, parser.ts, start - 1)
8584
).left;
8685

87-
expression.typeAnnotation = read_type_annotation(parser, optional_allowed);
86+
expression.typeAnnotation = read_type_annotation(parser);
8887
if (expression.typeAnnotation) {
8988
expression.end = expression.typeAnnotation.end;
9089
}
@@ -97,19 +96,12 @@ export default function read_pattern(parser, optional_allowed = false) {
9796

9897
/**
9998
* @param {import('../index.js').Parser} parser
100-
* @param {boolean} [optional_allowed]
10199
* @returns {any}
102100
*/
103-
function read_type_annotation(parser, optional_allowed = false) {
101+
function read_type_annotation(parser) {
104102
const start = parser.index;
105103
parser.allow_whitespace();
106104

107-
if (optional_allowed && parser.eat('?')) {
108-
// Acorn-TS puts the optional info as a property on the surrounding node.
109-
// We spare the work here because it doesn't matter for us anywhere else.
110-
parser.allow_whitespace();
111-
}
112-
113105
if (!parser.eat(':')) {
114106
parser.index = start;
115107
return undefined;

packages/svelte/src/compiler/phases/1-parse/state/tag.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -269,28 +269,30 @@ function open(parser) {
269269
e.expected_identifier(parser.index);
270270
}
271271

272-
let slice_end = parser.index;
272+
parser.allow_whitespace();
273273

274-
parser.eat('(', true);
274+
const params_start = parser.index;
275275

276+
parser.eat('(', true);
276277
let parentheses = 1;
277-
let params = '';
278278

279-
while (!parser.match(')') || parentheses !== 1) {
279+
while (parser.index < parser.template.length && (!parser.match(')') || parentheses !== 1)) {
280280
if (parser.match('(')) parentheses++;
281281
if (parser.match(')')) parentheses--;
282-
params += parser.read(/^./);
282+
parser.index += 1;
283283
}
284284

285+
parser.eat(')', true);
286+
287+
const prelude = parser.template.slice(0, params_start).replace(/\S/g, ' ');
288+
const params = parser.template.slice(params_start, parser.index);
289+
285290
let function_expression = /** @type {import('estree').ArrowFunctionExpression} */ (
286-
parse_expression_at(
287-
parser.template.slice(0, slice_end).replace(/\S/g, ' ') + `(${params}) => {}`,
288-
parser.ts,
289-
0
290-
)
291+
parse_expression_at(prelude + `${params} => {}`, parser.ts, params_start)
291292
);
292293

293-
parser.index += 2;
294+
parser.allow_whitespace();
295+
parser.eat('}', true);
294296

295297
/** @type {ReturnType<typeof parser.append<import('#compiler').SnippetBlock>>} */
296298
const block = parser.append({

packages/svelte/src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* https://svelte.dev/docs/svelte-compiler#svelte-version
77
* @type {string}
88
*/
9-
export const VERSION = '5.0.0-next.163';
9+
export const VERSION = '5.0.0-next.164';
1010
export const PUBLIC_VERSION = '5';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
error: {
5+
code: 'expected_token',
6+
message: 'Expected token )',
7+
position: [31, 31]
8+
}
9+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{#snippet children(hi{/snippet}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
error: {
5+
code: 'expected_token',
6+
message: 'Expected token }',
7+
position: [20, 20]
8+
}
9+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{#snippet children()hi{/snippet}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!-- prettier-ignore -->
2+
{#snippet ok () }
3+
asd
4+
{/snippet}

playgrounds/demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
},
1414
"devDependencies": {
1515
"@sveltejs/vite-plugin-svelte": "^3.1.0",
16-
"express": "^4.19.2",
1716
"nodemon": "^3.0.3",
17+
"polka": "^1.0.0-next.25",
1818
"svelte": "workspace:*",
1919
"vite": "^5.0.13",
2020
"vite-plugin-inspect": "^0.8.4"

playgrounds/demo/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
33
import { fileURLToPath } from 'node:url';
4-
import express from 'express';
4+
import polka from 'polka';
55
import { createServer as createViteServer } from 'vite';
66

77
const PORT = process.env.PORT || '5173';
@@ -11,7 +11,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1111
process.env.NODE_ENV = 'development';
1212

1313
async function createServer() {
14-
const app = express();
14+
const app = polka();
1515

1616
const vite = await createViteServer({
1717
server: { middlewareMode: true },

0 commit comments

Comments
 (0)