|
|
|
@ -123,6 +123,8 @@ imperatively doing `element.addEventListener`, with that benefit that `attach` w
|
|
|
|
```js
|
|
|
|
```js
|
|
|
|
import { attach } from 'svelte/events';
|
|
|
|
import { attach } from 'svelte/events';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let element;
|
|
|
|
|
|
|
|
|
|
|
|
attach(element, 'click', () => {
|
|
|
|
attach(element, 'click', () => {
|
|
|
|
console.log('click the element!');
|
|
|
|
console.log('click the element!');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -133,6 +135,8 @@ Additionally, `attach` returns a function that easily allows for removal of the
|
|
|
|
```js
|
|
|
|
```js
|
|
|
|
import { attach } from 'svelte/events';
|
|
|
|
import { attach } from 'svelte/events';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let element;
|
|
|
|
|
|
|
|
|
|
|
|
const remove = attach(element, 'click', () => {
|
|
|
|
const remove = attach(element, 'click', () => {
|
|
|
|
console.log('click the element!');
|
|
|
|
console.log('click the element!');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|