Skip to content

Commit 7e48aea

Browse files
Sync svelte docs (#1335)
sync svelte docs Co-authored-by: svelte-docs-bot[bot] <196124396+svelte-docs-bot[bot]@users.noreply.github.com>
1 parent 9e7304d commit 7e48aea

File tree

5 files changed

+55
-6
lines changed

5 files changed

+55
-6
lines changed

apps/svelte.dev/content/docs/svelte/03-template-syntax/11-bind.md

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

121+
## `<input bind:indeterminate>`
122+
123+
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:
124+
125+
```svelte
126+
<script>
127+
let checked = $state(false);
128+
let indeterminate = $state(true);
129+
</script>
130+
131+
<form>
132+
<input type="checkbox" bind:checked bind:indeterminate>
133+
134+
{#if indeterminate}
135+
waiting...
136+
{:else if checked}
137+
checked
138+
{:else}
139+
unchecked
140+
{/if}
141+
</form>
142+
```
143+
121144
## `<input bind:group>`
122145

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

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

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

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

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

289-
> [!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`.
321+
> [!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.
290322
291323
## bind:this
292324

apps/svelte.dev/content/docs/svelte/07-misc/02-testing.md

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

88
## Unit and integration testing using Vitest
99

10-
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/).
10+
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.
1111

12-
To get started, install Vitest:
12+
To setup Vitest manually, first install it:
1313

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

256256
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/).
257257

258-
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`.
258+
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.
259259

260-
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:
260+
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:
261261

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

apps/svelte.dev/content/docs/svelte/07-misc/99-faq.md

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

8383
Some resources for getting started with testing:
8484

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

apps/svelte.dev/content/docs/svelte/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
```

apps/svelte.dev/content/docs/svelte/98-reference/30-compiler-warnings.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,14 @@ Attributes should not contain ':' characters to prevent ambiguity with Svelte di
607607
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
608608
```
609609

610+
### bidirectional_control_characters
611+
612+
```
613+
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
614+
```
615+
616+
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.
617+
610618
### bind_invalid_each_rest
611619

612620
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy