Skip to content

Commit 6129e86

Browse files
Rich-HarrisRich Harris
and
Rich Harris
authored
Tweaks (#276)
* tweaks * . * remove duplicates --------- Co-authored-by: Rich Harris <[email protected]>
1 parent 20c6b25 commit 6129e86

File tree

40 files changed

+36
-595
lines changed

40 files changed

+36
-595
lines changed

content/tutorial/01-svelte/03-props/01-declaring-props/app-b/src/lib/App.svelte

Lines changed: 0 additions & 5 deletions
This file was deleted.

content/tutorial/01-svelte/05-events/02-inline-handlers/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ You can also declare event handlers inline:
1515
</script>
1616
1717
<div
18-
+++on:mousemove={(e) => {
18+
on:mousemove={+++(e) => {
1919
m = { x: e.clientX, y: e.clientY };
20-
}}+++
20+
}+++}
2121
>
2222
The mouse position is {m.x} x {m.y}
2323
</div>

content/tutorial/01-svelte/05-events/04-component-events/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Components can also dispatch events. To do so, they must create an event dispatc
66

77
```svelte
88
<script>
9-
import { createEventDispatcher } from 'svelte';
9+
+++import { createEventDispatcher } from 'svelte';+++
1010
11-
const dispatch = createEventDispatcher();
11+
+++const dispatch = createEventDispatcher();+++
1212
1313
function sayHello() {
1414
dispatch('message', {
@@ -20,8 +20,10 @@ Components can also dispatch events. To do so, they must create an event dispatc
2020

2121
> `createEventDispatcher` must be called when the component is first instantiated — you can't do it later inside e.g. a `setTimeout` callback. This links `dispatch` to the component instance.
2222
23-
Notice that the `App` component is listening to the messages dispatched by `Inner` component thanks to the `on:message` directive. This directive is an attribute prefixed with `on:` followed by the event name that we are dispatching (in this case, `message`).
23+
Then, add an `on:message` handler in `App.svelte`:
2424

25-
Without this attribute, messages would still be dispatched, but the App would not react to it. You can try removing the `on:message` attribute and pressing the button again.
25+
```svelte
26+
<Inner +++on:message={handleMessage}+++ />
27+
```
2628

27-
> You can also try changing the event name to something else. For instance, change `dispatch('message')` to `dispatch('myevent')` in `Inner.svelte` and change the attribute name from `on:message` to `on:myevent` in the `App.svelte` component.
29+
> You can also try changing the event name to something else. For instance, change `dispatch('message')` to `dispatch('myevent')` in `Inner.svelte` and change the attribute name from `on:message` to `on:myevent` in `App.svelte`.

content/tutorial/01-svelte/05-events/04-component-events/app-a/src/lib/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
}
77
</script>
88

9-
<Inner on:message={handleMessage} />
9+
<Inner />

content/tutorial/01-svelte/05-events/04-component-events/app-a/src/lib/Inner.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script>
2-
// setup code goes here
3-
4-
function sayHello() {}
2+
function sayHello() {
3+
dispatch('message', {
4+
text: 'Hello!'
5+
});
6+
}
57
</script>
68

79
<button on:click={sayHello}>

content/tutorial/01-svelte/05-events/05-event-forwarding/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Unlike DOM events, component events don't _bubble_. If you want to listen to an
66

77
In this case, we have the same `App.svelte` and `Inner.svelte` as in the [previous chapter](/tutorial/component-events), but there's now an `Outer.svelte` component that contains `<Inner/>`.
88

9-
One way we could solve the problem is adding `createEventDispatcher` to `Outer.svelte`, listening for the `message` event, and creating a handler for it:
9+
One way we _could_ solve the problem is adding `createEventDispatcher` to `Outer.svelte`, listening for the `message` event, and creating a handler for it:
1010

1111
```svelte
1212
<script>

content/tutorial/01-svelte/05-events/05-event-forwarding/app-b/src/lib/App.svelte

Lines changed: 0 additions & 9 deletions
This file was deleted.

content/tutorial/01-svelte/05-events/05-event-forwarding/app-b/src/lib/Inner.svelte

Lines changed: 0 additions & 15 deletions
This file was deleted.

content/tutorial/01-svelte/05-events/06-dom-event-forwarding/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Event forwarding works for DOM events too.
77
We want to get notified of clicks on our `<CustomButton>` — to do that, we just need to forward `click` events on the `<button>` element in `CustomButton.svelte`:
88

99
```svelte
10-
<button on:click>
10+
<button +++on:click+++>
1111
Click me
1212
</button>
1313
```

content/tutorial/01-svelte/05-events/06-dom-event-forwarding/app-a/src/lib/CustomButton.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<button>Click me</button>
1+
<button>
2+
Click me
3+
</button>
24

35
<style>
46
button {

content/tutorial/01-svelte/05-events/06-dom-event-forwarding/app-b/src/lib/App.svelte

Lines changed: 0 additions & 9 deletions
This file was deleted.

content/tutorial/01-svelte/05-events/06-dom-event-forwarding/app-b/src/lib/CustomButton.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<button on:click>Click me</button>
1+
<button on:click>
2+
Click me
3+
</button>
24

35
<style>
46
button {

content/tutorial/01-svelte/07-lifecycle/02-ondestroy/app-b/src/lib/App.svelte

Lines changed: 0 additions & 23 deletions
This file was deleted.

content/tutorial/01-svelte/07-lifecycle/02-ondestroy/app-b/src/lib/Timer.svelte

Lines changed: 0 additions & 22 deletions
This file was deleted.

content/tutorial/01-svelte/08-stores/01-writable-stores/app-b/src/lib/App.svelte

Lines changed: 0 additions & 18 deletions
This file was deleted.

content/tutorial/01-svelte/08-stores/01-writable-stores/app-b/src/lib/stores.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

content/tutorial/01-svelte/08-stores/02-auto-subscriptions/app-b/src/lib/Decrementer.svelte

Lines changed: 0 additions & 9 deletions
This file was deleted.

content/tutorial/01-svelte/08-stores/02-auto-subscriptions/app-b/src/lib/Incrementer.svelte

Lines changed: 0 additions & 9 deletions
This file was deleted.

content/tutorial/01-svelte/08-stores/02-auto-subscriptions/app-b/src/lib/Resetter.svelte

Lines changed: 0 additions & 9 deletions
This file was deleted.

content/tutorial/01-svelte/08-stores/02-auto-subscriptions/app-b/src/lib/stores.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

content/tutorial/01-svelte/08-stores/03-readable-stores/app-b/src/lib/App.svelte

Lines changed: 0 additions & 15 deletions
This file was deleted.

content/tutorial/01-svelte/08-stores/04-derived-stores/app-b/src/lib/App.svelte

Lines changed: 0 additions & 21 deletions
This file was deleted.

content/tutorial/01-svelte/08-stores/05-custom-stores/app-b/src/lib/App.svelte

Lines changed: 0 additions & 9 deletions
This file was deleted.

content/tutorial/01-svelte/08-stores/06-store-bindings/app-b/src/lib/stores.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

content/tutorial/02-sveltekit/05-api-routes/01-get-handlers/app-b/src/routes/+page.svelte

Lines changed: 0 additions & 15 deletions
This file was deleted.

content/tutorial/02-sveltekit/05-api-routes/02-post-put-patch-delete/app-b/src/routes/+page.svelte

Lines changed: 0 additions & 1 deletion
This file was deleted.

content/tutorial/03-advanced-svelte/05-bindings/06-component-bindings/app-b/src/lib/Keypad.svelte

Lines changed: 0 additions & 44 deletions
This file was deleted.

content/tutorial/03-advanced-svelte/05-bindings/07-component-this/app-b/src/lib/InputField.svelte

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)