Skip to content

Commit 3f0b41b

Browse files
authored
docs: annotate notes as such (#13564)
1 parent 4578d4f commit 3f0b41b

16 files changed

+25
-25
lines changed

documentation/docs/02-template-syntax/01-component-fundamentals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ A `<script>` block contains JavaScript (or TypeScript, when adding the `lang="ts
2929

3030
Svelte uses the `$props` rune to declare _properties_ or _props_, which means describing the public interface of the component which becomes accessible to consumers of the component.
3131

32-
> `$props` is one of several runes, which are special hints for Svelte's compiler to make things reactive.
32+
> [!NOTE] `$props` is one of several runes, which are special hints for Svelte's compiler to make things reactive.
3333
3434
```svelte
3535
<script>

documentation/docs/02-template-syntax/02-basic-markup.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ An element or component can have multiple spread attributes, interspersed with r
8888
<Widget {...things} />
8989
```
9090

91-
> The `value` attribute of an `input` element or its children `option` elements must not be set with spread attributes when using `bind:group` or `bind:checked`. Svelte needs to be able to see the element's `value` directly in the markup in these cases so that it can link it to the bound variable.
91+
> [!NOTE] The `value` attribute of an `input` element or its children `option` elements must not be set with spread attributes when using `bind:group` or `bind:checked`. Svelte needs to be able to see the element's `value` directly in the markup in these cases so that it can link it to the bound variable.
9292
93-
> Sometimes, the attribute order matters as Svelte sets attributes sequentially in JavaScript. For example, `<input type="range" min="0" max="1" value={0.5} step="0.1"/>`, Svelte will attempt to set the value to `1` (rounding up from 0.5 as the step by default is 1), and then set the step to `0.1`. To fix this, change it to `<input type="range" min="0" max="1" step="0.1" value={0.5}/>`.
93+
> [!NOTE] Sometimes, the attribute order matters as Svelte sets attributes sequentially in JavaScript. For example, `<input type="range" min="0" max="1" value={0.5} step="0.1"/>`, Svelte will attempt to set the value to `1` (rounding up from 0.5 as the step by default is 1), and then set the step to `0.1`. To fix this, change it to `<input type="range" min="0" max="1" step="0.1" value={0.5}/>`.
9494
95-
> Another example is `<img src="..." loading="lazy" />`. Svelte will set the img `src` before making the img element `loading="lazy"`, which is probably too late. Change this to `<img loading="lazy" src="...">` to make the image lazily loaded.
95+
> [!NOTE] Another example is `<img src="..." loading="lazy" />`. Svelte will set the img `src` before making the img element `loading="lazy"`, which is probably too late. Change this to `<img loading="lazy" src="...">` to make the image lazily loaded.
9696
9797
## Events
9898

@@ -177,7 +177,7 @@ The expression will be stringified and escaped to prevent code injections. If yo
177177
{@html potentiallyUnsafeHtmlString}
178178
```
179179

180-
> Make sure that you either escape the passed string or only populate it with values that are under your control in order to prevent [XSS attacks](https://owasp.org/www-community/attacks/xss/)
180+
> [!NOTE] Make sure that you either escape the passed string or only populate it with values that are under your control in order to prevent [XSS attacks](https://owasp.org/www-community/attacks/xss/)
181181
182182
## Comments
183183

documentation/docs/02-template-syntax/04-snippets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Any content inside the component tags that is _not_ a snippet declaration implic
184184
<button>{@render children()}</button>
185185
```
186186

187-
> Note that you cannot have a prop called `children` if you also have content inside the component — for this reason, you should avoid having props with that name
187+
> [!NOTE] Note that you cannot have a prop called `children` if you also have content inside the component — for this reason, you should avoid having props with that name
188188
189189
You can declare snippet props as being optional. You can either use optional chaining to not render anything if the snippet isn't set...
190190

documentation/docs/02-template-syntax/05-styles-and-classes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ To apply styles to a group of selectors globally, create a `:global {...}` block
8585
</style>
8686
```
8787

88-
> The second example above could also be written as an equivalent `.a :global .b .c .d` selector, where everything after the `:global` is unscoped, though the nested form is preferred.
88+
> [!NOTE] The second example above could also be written as an equivalent `.a :global .b .c .d` selector, where everything after the `:global` is unscoped, though the nested form is preferred.
8989
9090
## Nested style tags
9191

@@ -207,7 +207,7 @@ For SVG namespace, the example above desugars into using `<g>` instead:
207207
</g>
208208
```
209209

210-
> Since this is an extra `<div>` (or `<g>`), beware that your CSS structure might accidentally target this. Be mindful of this added wrapper element when using this feature.
210+
> [!NOTE] Since this is an extra `<div>` (or `<g>`), beware that your CSS structure might accidentally target this. Be mindful of this added wrapper element when using this feature.
211211
212212
Svelte's CSS Variables support allows for easily themeable components:
213213

documentation/docs/02-template-syntax/06-transitions-and-animations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Transitions are local by default. Local transitions only play when the block the
7979
{/if}
8080
```
8181

82-
> By default intro transitions will not play on first render. You can modify this behaviour by setting `intro: true` when you [create a component](imperative-component-api) and marking the transition as `global`.
82+
> [!NOTE] By default intro transitions will not play on first render. You can modify this behaviour by setting `intro: true` when you [create a component](imperative-component-api) and marking the transition as `global`.
8383
8484
## Transition parameters
8585

@@ -132,7 +132,7 @@ The function is called repeatedly _before_ the transition begins, with different
132132

133133
A custom transition function can also return a `tick` function, which is called _during_ the transition with the same `t` and `u` arguments.
134134

135-
> If it's possible to use `css` instead of `tick`, do so — CSS animations can run off the main thread, preventing jank on slower devices.
135+
> [!NOTE] If it's possible to use `css` instead of `tick`, do so — CSS animations can run off the main thread, preventing jank on slower devices.
136136
137137
```svelte
138138
<!--- file: App.svelte --->
@@ -377,7 +377,7 @@ The function is called repeatedly _before_ the animation begins, with different
377377

378378
A custom animation function can also return a `tick` function, which is called _during_ the animation with the same `t` and `u` arguments.
379379

380-
> If it's possible to use `css` instead of `tick`, do so — CSS animations can run off the main thread, preventing jank on slower devices.
380+
> [!NOTE] If it's possible to use `css` instead of `tick`, do so — CSS animations can run off the main thread, preventing jank on slower devices.
381381
382382
```svelte
383383
<!--- file: App.svelte --->

documentation/docs/02-template-syntax/07-actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Actions are functions that are called when an element is created. They can retur
4848

4949
An action can have a parameter. If the returned value has an `update` method, it will be called immediately after Svelte has applied updates to the markup whenever that parameter changes.
5050

51-
> Don't worry that we're redeclaring the `foo` function for every component instance — Svelte will hoist any functions that don't depend on local state out of the component definition.
51+
> [!NOTE] Don't worry that we're redeclaring the `foo` function for every component instance — Svelte will hoist any functions that don't depend on local state out of the component definition.
5252
5353
```svelte
5454
<!--- file: App.svelte --->

documentation/docs/02-template-syntax/08-bindings.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ On `<input>` elements with `type="file"`, you can use `bind:files` to get the [`
6060

6161
`FileList` objects also cannot be modified, so if you want to e.g. delete a single file from the list, you need to create a new `DataTransfer` object and add the files you want to keep.
6262

63-
> `DataTransfer` may not be available in server-side JS runtimes. Leaving the state that is bound to `files` uninitialized prevents potential errors if components are server-side rendered.
63+
> [!NOTE] `DataTransfer` may not be available in server-side JS runtimes. Leaving the state that is bound to `files` uninitialized prevents potential errors if components are server-side rendered.
6464
6565
If you're using `bind:` directives together with `on` event attributes, the binding will always fire before the event attribute.
6666

@@ -231,7 +231,7 @@ Inputs that work together can use `bind:group`.
231231
<input type="checkbox" bind:group={fillings} value="Guac (extra)" />
232232
```
233233

234-
> `bind:group` only works if the inputs are in the same Svelte component.
234+
> [!NOTE] `bind:group` only works if the inputs are in the same Svelte component.
235235
236236
## bind:this
237237

@@ -277,7 +277,7 @@ Components also support `bind:this`, allowing you to interact with component ins
277277
</script>
278278
```
279279

280-
> Note that we can't do `{cart.empty}` since `cart` is `undefined` when the button is first rendered and throws an error.
280+
> [!NOTE] Note that we can't do `{cart.empty}` since `cart` is `undefined` when the button is first rendered and throws an error.
281281
282282
## bind:_property_ for components
283283

documentation/docs/02-template-syntax/09-special-elements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ All except `scrollX` and `scrollY` are readonly.
110110
<svelte:window bind:scrollY={y} />
111111
```
112112

113-
> Note that the page will not be scrolled to the initial value to avoid accessibility issues. Only subsequent changes to the bound variable of `scrollX` and `scrollY` will cause scrolling. However, if the scrolling behaviour is desired, call `scrollTo()` in `onMount()`.
113+
> [!NOTE] Note that the page will not be scrolled to the initial value to avoid accessibility issues. Only subsequent changes to the bound variable of `scrollX` and `scrollY` will cause scrolling. However, if the scrolling behaviour is desired, call `scrollTo()` in `onMount()`.
114114
115115
## `<svelte:document>`
116116

documentation/docs/03-runes/01-state.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Todo {
4141
}
4242
```
4343

44-
> In this example, the compiler transforms `done` and `text` into `get`/`set` methods on the class prototype referencing private fields
44+
> [!NOTE] In this example, the compiler transforms `done` and `text` into `get`/`set` methods on the class prototype referencing private fields
4545
4646
Objects and arrays are made deeply reactive by wrapping them with [`Proxies`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy). What that means is that in the following example, we can mutate the `entries` object and the UI will still update - but only the list item that is actually changed will rerender:
4747

@@ -60,7 +60,7 @@ Objects and arrays are made deeply reactive by wrapping them with [`Proxies`](ht
6060
<button onclick={() => (entries[1].text = 'baz')}>change second entry text</button>
6161
```
6262

63-
> Only POJOs (plain old JavaScript objects) are made deeply reactive. Reactivity will stop at class boundaries and leave those alone
63+
> [!NOTE] Only POJOs (plain old JavaScript objects) are made deeply reactive. Reactivity will stop at class boundaries and leave those alone
6464
6565
## `$state.raw`
6666

documentation/docs/03-runes/02-side-effects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ In general, `$effect` is best considered something of an escape hatch — useful
164164
</script>
165165
```
166166

167-
> For things that are more complicated than a simple expression like `count * 2`, you can also use [`$derived.by`](#$derived-by).
167+
> [!NOTE] For things that are more complicated than a simple expression like `count * 2`, you can also use [`$derived.by`](#$derived-by).
168168
169169
You might be tempted to do something convoluted with effects to link one value to another. The following example shows two inputs for "money spent" and "money left" that are connected to each other. If you update one, the other should update accordingly. Don't use effects for this ([demo](/#H4sIAAAAAAAACpVRy2rDMBD8lWXJwYE0dg-9KFYg31H3oNirIJBlYa1DjPG_F8l1XEop9LgzOzP7mFAbSwHF-4ROtYQCL97jAXn0sQh3skx4wNANfR2RMtS98XyuXMWWGLhjZUHCa1GcVix4cgwSdoEVU1bsn4wl_Y1I2kS6inekNdWcZXuQZ5giFDWpfwl5WYyT2fynbB1g1UWbTVbm2w6utOpKNq1TGucHhri6rLBX7kYVwtW4RtyVHUhOyXeGVj3klLxnyJP0i8lXNJUx6en-v6A48K85kTimpi0sYj-yAo-Wlh9FcL1LY4K3ahSgLT1OC3ZTXkBxfKN2uVC6T5LjAduuMdpQg4L7geaP-RNHPuClMQIAAA==)):
170170

documentation/docs/04-runtime/01-stores.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ readableStore.set(2); // ERROR
250250

251251
Generally, you should read the value of a store by subscribing to it and using the value as it changes over time. Occasionally, you may need to retrieve the value of a store to which you're not subscribed. `get` allows you to do so.
252252

253-
> This works by creating a subscription, reading the value, then unsubscribing. It's therefore not recommended in hot code paths.
253+
> [!NOTE] This works by creating a subscription, reading the value, then unsubscribing. It's therefore not recommended in hot code paths.
254254
255255
```ts
256256
// @filename: ambient.d.ts

documentation/docs/04-runtime/02-context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The context is then available to children of the component (including slotted co
6262
- the state is not global, it's scoped to the component. That way it's safe to render your components on the server and not leak state
6363
- it's clear that the state is not global but rather scoped to a specific component tree and therefore can't be used in other parts of your app
6464

65-
> `setContext`/`getContext` must be called during component initialisation.
65+
> [!NOTE] `setContext`/`getContext` must be called during component initialisation.
6666
6767
Context is not inherently reactive. If you need reactive values in context then you can pass a `$state` object into context, whos properties _will_ be reactive.
6868

documentation/docs/04-runtime/03-lifecycle-hooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If a function is returned from `onMount`, it will be called when the component i
4141
</script>
4242
```
4343

44-
> This behaviour will only work when the function passed to `onMount` _synchronously_ returns a value. `async` functions always return a `Promise`, and as such cannot _synchronously_ return a function.
44+
> [!NOTE] This behaviour will only work when the function passed to `onMount` _synchronously_ returns a value. `async` functions always return a `Promise`, and as such cannot _synchronously_ return a function.
4545
4646
## `onDestroy`
4747

documentation/docs/05-misc/01-debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ A convenient way to find the origin of some change is to pass `console.trace` to
4848
$inspect(stuff).with(console.trace);
4949
```
5050

51-
> `$inspect` only works during development. In a production build it becomes a noop.
51+
> [!NOTE] `$inspect` only works during development. In a production build it becomes a noop.
5252
5353
## @debug
5454

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ test('Effect', () => {
9999

100100
It is possible to test your components in isolation using Vitest.
101101

102-
> Before writing component tests, think about whether you actually need to test the component, or if it's more about the logic _inside_ the component. If so, consider extracting out that logic to test it in isolation, without the overhead of a component
102+
> [!NOTE] Before writing component tests, think about whether you actually need to test the component, or if it's more about the logic _inside_ the component. If so, consider extracting out that logic to test it in isolation, without the overhead of a component
103103
104104
To get started, install jsdom (a library that shims DOM APIs):
105105

documentation/docs/05-misc/03-typescript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ In both cases, a `svelte.config.js` with `vitePreprocess` will be added. Vite/Sv
7575

7676
If you're using tools like Rollup or Webpack instead, install their respective Svelte plugins. For Rollup that's [rollup-plugin-svelte](https://github.com/sveltejs/rollup-plugin-svelte) and for Webpack that's [svelte-loader](https://github.com/sveltejs/svelte-loader). For both, you need to install `typescript` and `svelte-preprocess` and add the preprocessor to the plugin config (see the respective READMEs for more info). If you're starting a new project, you can also use the [rollup](https://github.com/sveltejs/template) or [webpack](https://github.com/sveltejs/template-webpack) template to scaffold the setup from a script.
7777

78-
> If you're starting a new project, we recommend using SvelteKit or Vite instead
78+
> [!NOTE] If you're starting a new project, we recommend using SvelteKit or Vite instead
7979
8080
## Typing `$props`
8181

0 commit comments

Comments
 (0)