Svelte · Junior · Question 68 of 76
What does the use: directive (action) receive?
<script>
function tooltip(node, text) {
// set up
return { destroy() { /* clean up */ } };
}
</script>
<button use:tooltip={"Save changes"}>Save</button>- ✓Correct answer: The DOM element and an optional parameter, when the element is mounted
- 2The component instance
- 3Only an event object
Explanation
Actions are still supported, but Svelte 5.29+ recommends attachments ({@attach}), which are more flexible and react to state changes.