Sometimes Svelte applications need to tap into DOM functionality that is not directly supported by Svelte. Examples include
- Moving focus to an input where the user is expected to enter data
- Setting the cursor position and selected text inside an input
- Calling methods on a dialog element
- Allowing users to drag particular elements onto others
All of these require going beyond simply writing the HTML to be rendered inside a Svelte component definition. Svelte supports this by providing access to the DOM elements it creates. Component code can modify the properties of these DOM elements and call methods on them. This chapter presents several such scenarios.