Skip to content

Commit 84121f7

Browse files
author
Rich Harris
committed
tidy up
1 parent 9b2d153 commit 84121f7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

content/tutorial/03-advanced-svelte/09-special-elements/07-svelte-document/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
title: <svelte:document>
33
---
44

5-
Similar to `<svelte:window>`, the `<svelte:document>` element allows you to listen for events that fire on `document`. This is useful with events like `selectionchange`, which doesn't fire on `window`.
5+
The `<svelte:document>` element allows you to listen for events that fire on `document`. This is useful with events like `selectionchange`, which doesn't fire on `window`.
66

77
Add the `selectionchange` handler to the `<svelte:document>` tag:
88

99
```svelte
1010
/// file: App.svelte
11-
<svelte:document on:selectionchange={handleSelectionChange} />
11+
<svelte:document +++on:selectionchange={handleSelectionChange}+++ />
1212
```
1313

14-
> Avoid `mouseenter` and `mouseleave` handlers on this element, these events are not fired on `document` in all browsers. Use `<svelte:body>` for this instead.
14+
> Avoid `mouseenter` and `mouseleave` handlers on this element, as these events are not fired on `document` in all browsers. Use `<svelte:body>` instead.

content/tutorial/03-advanced-svelte/09-special-elements/07-svelte-document/app-a/src/lib/App.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const handleSelectionChange = (e) => selection = document.getSelection();
55
</script>
66

7-
<svelte:body />
7+
<svelte:document />
88

9-
<p>Select this text to fire events</p>
9+
<h1>Select this text to fire events</h1>
1010
<p>Selection: {selection}</p>

content/tutorial/03-advanced-svelte/09-special-elements/07-svelte-document/app-b/src/lib/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
<svelte:document on:selectionchange={handleSelectionChange} />
88

9-
<p>Select this text to fire events</p>
9+
<h1>Select this text to fire events</h1>
1010
<p>Selection: {selection}</p>

0 commit comments

Comments
 (0)