Skip to content

Commit aebef7d

Browse files
committed
Merge branch 'main' into pr/15813
2 parents 42eb907 + 8fc8bc7 commit aebef7d

File tree

52 files changed

+608
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+608
-198
lines changed

.changeset/hot-seals-hang.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: remove unncessary guards that require CSP privilege when removing event attributes

benchmarking/compare/index.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,37 @@ for (let i = 0; i < results[0].length; i += 1) {
6767
for (const metric of ['time', 'gc_time']) {
6868
const times = results.map((result) => +result[i][metric]);
6969
let min = Infinity;
70+
let max = -Infinity;
7071
let min_index = -1;
7172

7273
for (let b = 0; b < times.length; b += 1) {
73-
if (times[b] < min) {
74-
min = times[b];
74+
const time = times[b];
75+
76+
if (time < min) {
77+
min = time;
7578
min_index = b;
7679
}
80+
81+
if (time > max) {
82+
max = time;
83+
}
7784
}
7885

7986
if (min !== 0) {
80-
console.group(`${metric}: fastest is ${branches[min_index]}`);
87+
console.group(`${metric}: fastest is ${char(min_index)} (${branches[min_index]})`);
8188
times.forEach((time, b) => {
82-
console.log(`${branches[b]}: ${time.toFixed(2)}ms (${((time / min) * 100).toFixed(2)}%)`);
89+
const SIZE = 20;
90+
const n = Math.round(SIZE * (time / max));
91+
92+
console.log(`${char(b)}: ${'◼'.repeat(n)}${' '.repeat(SIZE - n)} ${time.toFixed(2)}ms`);
8393
});
8494
console.groupEnd();
8595
}
8696
}
8797

8898
console.groupEnd();
8999
}
100+
101+
function char(i) {
102+
return String.fromCharCode(97 + i);
103+
}

documentation/docs/02-runes/07-$inspect.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ This rune, added in 5.14, causes the surrounding function to be _traced_ in deve
5252
import { doSomeWork } from './elsewhere';
5353
5454
$effect(() => {
55+
+++// $inspect.trace must be the first statement of a function body+++
5556
+++$inspect.trace();+++
5657
doSomeWork();
5758
});

documentation/docs/03-template-syntax/11-bind.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,29 @@ Since 5.6.0, if an `<input>` has a `defaultChecked` attribute and is part of a f
117117
</form>
118118
```
119119

120+
## `<input bind:indeterminate>`
121+
122+
Checkboxes can be in an [indeterminate](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/indeterminate) state, independently of whether they are checked or unchecked:
123+
124+
```svelte
125+
<script>
126+
let checked = $state(false);
127+
let indeterminate = $state(true);
128+
</script>
129+
130+
<form>
131+
<input type="checkbox" bind:checked bind:indeterminate>
132+
133+
{#if indeterminate}
134+
waiting...
135+
{:else if checked}
136+
checked
137+
{:else}
138+
unchecked
139+
{/if}
140+
</form>
141+
```
142+
120143
## `<input bind:group>`
121144

122145
Inputs that work together can use `bind:group`.
@@ -227,6 +250,7 @@ You can give the `<select>` a default value by adding a `selected` attribute to
227250
- [`seeking`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seeking_event)
228251
- [`ended`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/ended)
229252
- [`readyState`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState)
253+
- [`played`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/played)
230254

231255
```svelte
232256
<audio src={clip} bind:duration bind:currentTime bind:paused></audio>
@@ -254,6 +278,10 @@ You can give the `<select>` a default value by adding a `selected` attribute to
254278
</details>
255279
```
256280

281+
## `window` and `document`
282+
283+
To bind to properties of `window` and `document`, see [`<svelte:window>`](svelte-window) and [`<svelte:document>`](svelte-document).
284+
257285
## Contenteditable bindings
258286

259287
Elements with the `contenteditable` attribute support the following bindings:
@@ -278,14 +306,18 @@ All visible elements have the following readonly bindings, measured with a `Resi
278306
- [`clientHeight`](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight)
279307
- [`offsetWidth`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetWidth)
280308
- [`offsetHeight`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight)
309+
- [`contentRect`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentRect)
310+
- [`contentBoxSize`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentBoxSize)
311+
- [`borderBoxSize`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/borderBoxSize)
312+
- [`devicePixelContentBoxSize`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/devicePixelContentBoxSize)
281313

282314
```svelte
283315
<div bind:offsetWidth={width} bind:offsetHeight={height}>
284316
<Chart {width} {height} />
285317
</div>
286318
```
287319

288-
> [!NOTE] `display: inline` elements do not have a width or height (except for elements with 'intrinsic' dimensions, like `<img>` and `<canvas>`), and cannot be observed with a `ResizeObserver`. You will need to change the `display` style of these elements to something else, such as `inline-block`.
320+
> [!NOTE] `display: inline` elements do not have a width or height (except for elements with 'intrinsic' dimensions, like `<img>` and `<canvas>`), and cannot be observed with a `ResizeObserver`. You will need to change the `display` style of these elements to something else, such as `inline-block`. Note that CSS transformations do not trigger `ResizeObserver` callbacks.
289321
290322
## bind:this
291323

documentation/docs/07-misc/02-testing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Testing helps you write and maintain your code and guard against regressions. Te
66

77
## Unit and integration testing using Vitest
88

9-
Unit tests allow you to test small isolated parts of your code. Integration tests allow you to test parts of your application to see if they work together. If you're using Vite (including via SvelteKit), we recommend using [Vitest](https://vitest.dev/).
9+
Unit tests allow you to test small isolated parts of your code. Integration tests allow you to test parts of your application to see if they work together. If you're using Vite (including via SvelteKit), we recommend using [Vitest](https://vitest.dev/). You can use the Svelte CLI to [setup Vitest](/docs/cli/vitest) either during project creation or later on.
1010

11-
To get started, install Vitest:
11+
To setup Vitest manually, first install it:
1212

1313
```bash
1414
npm install -D vitest
@@ -254,9 +254,9 @@ When writing component tests that involve two-way bindings, context or snippet p
254254

255255
E2E (short for 'end to end') tests allow you to test your full application through the eyes of the user. This section uses [Playwright](https://playwright.dev/) as an example, but you can also use other solutions like [Cypress](https://www.cypress.io/) or [NightwatchJS](https://nightwatchjs.org/).
256256

257-
To get started with Playwright, either install it via [the VS Code extension](https://playwright.dev/docs/getting-started-vscode), or install it from the command line using `npm init playwright`. It is also part of the setup CLI when you run `npx sv create`.
257+
You can use the Svelte CLI to [setup Playwright](/docs/cli/playwright) either during project creation or later on. You can also [set it up with `npm init playwright`](https://playwright.dev/docs/intro). Additionally, you may also want to install an IDE plugin such as [the VS Code extension](https://playwright.dev/docs/getting-started-vscode) to be able to execute tests from inside your IDE.
258258

259-
After you've done that, you should have a `tests` folder and a Playwright config. You may need to adjust that config to tell Playwright what to do before running the tests - mainly starting your application at a certain port:
259+
If you've run `npm init playwright` or are not using Vite, you may need to adjust the Playwright config to tell Playwright what to do before running the tests - mainly starting your application at a certain port. For example:
260260

261261
```js
262262
/// file: playwright.config.js

documentation/docs/07-misc/99-faq.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ _End-to-End Tests_: To ensure your users are able to interact with your applicat
8181

8282
Some resources for getting started with testing:
8383

84+
- [Svelte docs on testing](/docs/svelte/testing)
85+
- [Setup Vitest using the Svelte CLI](/docs/cli/vitest)
8486
- [Svelte Testing Library](https://testing-library.com/docs/svelte-testing-library/example/)
8587
- [Svelte Component Testing in Cypress](https://docs.cypress.io/guides/component-testing/svelte/overview)
86-
- [Example using vitest](https://github.com/vitest-dev/vitest/tree/main/examples/sveltekit)
8788
- [Example using uvu test runner with JSDOM](https://github.com/lukeed/uvu/tree/master/examples/svelte)
8889
- [Test Svelte components using Vitest & Playwright](https://davipon.hashnode.dev/test-svelte-component-using-vitest-playwright)
8990
- [Component testing with WebdriverIO](https://webdriver.io/docs/component-testing/svelte)

documentation/docs/98-reference/.generated/compile-warnings.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,14 @@ Attributes should not contain ':' characters to prevent ambiguity with Svelte di
586586
Quoted attributes on components and custom elements will be stringified in a future version of Svelte. If this isn't what you want, remove the quotes
587587
```
588588

589+
### bidirectional_control_characters
590+
591+
```
592+
A bidirectional control character was detected in your code. These characters can be used to alter the visual direction of your code and could have unintended consequences
593+
```
594+
595+
Bidirectional control characters can alter the direction in which text appears to be in. For example, via control characters, you can make `defabc` look like `abcdef`. As a result, if you were to unknowingly copy and paste some code that has these control characters, they may alter the behavior of your code in ways you did not intend. See [trojansource.codes](https://trojansource.codes/) for more information.
596+
589597
### bind_invalid_each_rest
590598

591599
```

packages/svelte/CHANGELOG.md

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

3+
## 5.28.6
4+
5+
### Patch Changes
6+
7+
- fix: use `transform.read` for `ownership_validator.mutation` array ([#15848](https://github.com/sveltejs/svelte/pull/15848))
8+
9+
- fix: don't redeclare `$slots` ([#15849](https://github.com/sveltejs/svelte/pull/15849))
10+
11+
## 5.28.5
12+
13+
### Patch Changes
14+
15+
- fix: proxify the value in assignment shorthands to the private field ([#15862](https://github.com/sveltejs/svelte/pull/15862))
16+
17+
- fix: more frequently update `bind:buffered` to actual value ([#15874](https://github.com/sveltejs/svelte/pull/15874))
18+
19+
## 5.28.4
20+
21+
### Patch Changes
22+
23+
- fix: treat nullish expression as empty string ([#15901](https://github.com/sveltejs/svelte/pull/15901))
24+
25+
- fix: prevent invalid BigInt calls from blowing up at compile time ([#15900](https://github.com/sveltejs/svelte/pull/15900))
26+
27+
- fix: warn on bidirectional control characters ([#15893](https://github.com/sveltejs/svelte/pull/15893))
28+
29+
- fix: emit right error for a shadowed invalid rune ([#15892](https://github.com/sveltejs/svelte/pull/15892))
30+
31+
## 5.28.3
32+
33+
### Patch Changes
34+
35+
- chore: avoid microtasks when flushing sync ([#15895](https://github.com/sveltejs/svelte/pull/15895))
36+
37+
- fix: improve error message for migration errors when slot would be renamed ([#15841](https://github.com/sveltejs/svelte/pull/15841))
38+
39+
- fix: allow characters in the supplementary special-purpose plane ([#15823](https://github.com/sveltejs/svelte/pull/15823))
40+
41+
## 5.28.2
42+
43+
### Patch Changes
44+
45+
- fix: don't mark selector lists inside `:global` with multiple items as unused ([#15817](https://github.com/sveltejs/svelte/pull/15817))
46+
347
## 5.28.1
448

549
### Patch Changes

packages/svelte/messages/compile-warnings/misc.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## bidirectional_control_characters
2+
3+
> A bidirectional control character was detected in your code. These characters can be used to alter the visual direction of your code and could have unintended consequences
4+
5+
Bidirectional control characters can alter the direction in which text appears to be in. For example, via control characters, you can make `defabc` look like `abcdef`. As a result, if you were to unknowingly copy and paste some code that has these control characters, they may alter the behavior of your code in ways you did not intend. See [trojansource.codes](https://trojansource.codes/) for more information.
6+
17
## legacy_code
28

39
> `%code%` is no longer valid — please use `%suggestion%` instead

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

0 commit comments

Comments
 (0)