Skip to content

Commit 83a5c99

Browse files
authored
add note annotations (#361)
1 parent 33ffa0e commit 83a5c99

File tree

43 files changed

+49
-47
lines changed

Some content is hidden

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

43 files changed

+49
-47
lines changed

apps/svelte.dev/content/tutorial/01-svelte/01-introduction/01-welcome-to-svelte/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ You can build your entire app with Svelte (for example, using an application fra
1616

1717
## How to use this tutorial
1818

19-
> You'll need to have basic familiarity with HTML, CSS and JavaScript to understand Svelte.
19+
> [!NOTE] You'll need to have basic familiarity with HTML, CSS and JavaScript to understand Svelte.
2020
2121
This tutorial is split into four main parts:
2222

apps/svelte.dev/content/tutorial/01-svelte/01-introduction/05-nested-components/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ Add a `<script>` tag to the top of `App.svelte` that imports `Nested.svelte`...
2323

2424
Notice that even though `Nested.svelte` has a `<p>` element, the styles from `App.svelte` don't leak in.
2525

26-
> Component names are capitalised, to distinguish them from HTML elements.
26+
> [!NOTE] Component names are capitalised, to distinguish them from HTML elements.

apps/svelte.dev/content/tutorial/01-svelte/01-introduction/06-html-tags/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ In Svelte, you do this with the special `{@html ...}` tag:
1313
<p>{+++@html+++ string}</p>
1414
```
1515

16-
> **Warning!** Svelte doesn't perform any sanitization of the expression inside `{@html ...}` before it gets inserted into the DOM. This isn't an issue if the content is something you trust like an article you wrote yourself. However if it's some untrusted user content, e.g. a comment on an article, then it's critical that you manually escape it, otherwise you risk exposing your users to <a href="https://owasp.org/www-community/attacks/xss/" target="_blank">Cross-Site Scripting</a> (XSS) attacks.
16+
> [!NOTE] Important: Svelte doesn't perform any sanitization of the expression inside `{@html ...}` before it gets inserted into the DOM. This isn't an issue if the content is something you trust like an article you wrote yourself. However if it's some untrusted user content, e.g. a comment on an article, then it's critical that you manually escape it, otherwise you risk exposing your users to <a href="https://owasp.org/www-community/attacks/xss/" target="_blank">Cross-Site Scripting</a> (XSS) attacks.

apps/svelte.dev/content/tutorial/01-svelte/02-reactivity/02-deep-state/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ function addNumber() {
2929
}
3030
```
3131

32-
> Deep reactivity is implemented using [proxies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), and mutations to the proxy do not affect the original object.
32+
> [!NOTE] Deep reactivity is implemented using [proxies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), and mutations to the proxy do not affect the original object.

apps/svelte.dev/content/tutorial/01-svelte/02-reactivity/04-effects/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ So far we've talked about reactivity in terms of state. But that's only half of
66

77
The thing that reacts is called an _effect_. You've already encountered effects — the ones that Svelte creates on your behalf to update the DOM in response to state changes — but you can also create your own with the `$effect` rune.
88

9-
> Most of the time, you shouldn't. `$effect` is best thought of as an escape hatch, rather than something to use frequently. If you can put your side effects in an [event handler](dom-events), for example, that's almost always preferable.
9+
> [!NOTE] Most of the time, you shouldn't. `$effect` is best thought of as an escape hatch, rather than something to use frequently. If you can put your side effects in an [event handler](dom-events), for example, that's almost always preferable.
1010
1111
Let's say we want to use `setInterval` to keep track of how long the component has been mounted. Create the effect:
1212

@@ -45,4 +45,4 @@ The cleanup function is called immediately before the effect function re-runs wh
4545

4646
If the effect function doesn't read any state when it runs, it will only run once, when the component mounts.
4747

48-
> Effects do not run during server-side rendering.
48+
> [!NOTE] Effects do not run during server-side rendering.

apps/svelte.dev/content/tutorial/01-svelte/03-props/03-spread-props/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ We _could_ fix it by adding the prop...
2323
<PackageInfo +++{...pkg}+++ />
2424
```
2525

26-
> Conversely, you can get an object containing all the props that were passed into a component using a rest property...
26+
> [!NOTE] Conversely, you can get an object containing all the props that were passed into a component using a rest property...
2727
>
2828
> ```js
2929
> let { name, ...stuff } = $props();

apps/svelte.dev/content/tutorial/01-svelte/04-logic/04-each-blocks/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Instead of laboriously copying, pasting and editing, we can get rid of all but t
2020
</div>
2121
```
2222

23-
> The expression (`colors`, in this case) can be any iterable or array-like object — in other words, anything that works with [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from).
23+
> [!NOTE] The expression (`colors`, in this case) can be any iterable or array-like object — in other words, anything that works with [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from).
2424
2525
Now we need to use the `color` variable in place of `"red"`:
2626

apps/svelte.dev/content/tutorial/01-svelte/04-logic/05-keyed-each-blocks/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Click the 'Remove first thing' button a few times, and notice what happens:
1111
1. It removes the last component.
1212
2. It then updates the `name` value in the remaining DOM nodes, but not the emoji.
1313

14-
> If you're coming from React, this might seem strange, because you're used to the entire component re-rendering when state changes. Svelte works differently: the component 'runs' once, and subsequent updates are 'fine-grained'. This makes things faster and gives you more control.
14+
> [!NOTE] If you're coming from React, this might seem strange, because you're used to the entire component re-rendering when state changes. Svelte works differently: the component 'runs' once, and subsequent updates are 'fine-grained'. This makes things faster and gives you more control.
1515
1616
One way to fix it would be to make `emoji` a [`$derived`](derived-state) value. But it makes more sense to remove the first `<Thing>` component altogether than to remove the _last_ one and update all the others.
1717

@@ -24,4 +24,4 @@ To do that, we specify a unique _key_ for each iteration of the `each` block:
2424
{/each}
2525
```
2626

27-
> You can use any object as the key, as Svelte uses a `Map` internally — in other words you could do `(thing)` instead of `(thing.id)`. Using a string or number is generally safer, however, since it means identity persists without referential equality, for example when updating with fresh data from an API server.
27+
> [!NOTE] You can use any object as the key, as Svelte uses a `Map` internally — in other words you could do `(thing)` instead of `(thing.id)`. Using a string or number is generally safer, however, since it means identity persists without referential equality, for example when updating with fresh data from an API server.

apps/svelte.dev/content/tutorial/01-svelte/04-logic/06-await-blocks/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Most web applications have to deal with asynchronous data at some point. Svelte
1515
{/await}+++
1616
```
1717

18-
> Only the most recent `promise` is considered, meaning you don't need to worry about race conditions.
18+
> [!NOTE] Only the most recent `promise` is considered, meaning you don't need to worry about race conditions.
1919
2020
If you know that your promise can't reject, you can omit the `catch` block. You can also omit the first block if you don't want to show anything until the promise resolves:
2121

apps/svelte.dev/content/tutorial/01-svelte/06-bindings/04-select-bindings/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ We can also use `bind:value` with `<select>` elements:
1414

1515
Note that the `<option>` values are objects rather than strings. Svelte doesn't mind.
1616

17-
> Because we haven't set an initial value of `selected`, the binding will set it to the default value (the first in the list) automatically. Be careful though — until the binding is initialised, `selected` remains undefined, so we can't blindly reference e.g. `selected.id` in the template.
17+
> [!NOTE] Because we haven't set an initial value of `selected`, the binding will set it to the default value (the first in the list) automatically. Be careful though — until the binding is initialised, `selected` remains undefined, so we can't blindly reference e.g. `selected.id` in the template.

0 commit comments

Comments
 (0)