Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dy authored Jan 9, 2024
1 parent 1cc14c0 commit e24746d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,19 @@ foo.remove();
Listens for connected/disconnected events for the list of elements. (alternative to [fast-on-load](https://www.npmjs.com/package/fast-on-load))

```js
let nodes = [...document.querySelectorAll('.foo'), document.createElement('div')];
const nodes = [...document.querySelectorAll('.foo'), document.createElement('div')];

// assign listener
spect(nodes, el => {
console.log("connected");
return () => console.log("disconnected");
});

// modify DOM
document.body.appendChild(nodes.at(-1))
// ... "connected"

nodes.at(-1).remove()
// ... "disconnected"

document.body.appendChild(nodes.at(-1))
// ... "connected"
```

#### _<code>spect\`selector\`</code>_
Expand Down

0 comments on commit e24746d

Please sign in to comment.