Skip to content

Commit e8bab57

Browse files
authored
Merge pull request #2 from YuskaWu/fix/slotchange-not-work
fix: slogchange listener bug
2 parents abd8d1e + 9f8b3c1 commit e8bab57

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/main.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,15 @@ class GithubCorner extends HTMLElement {
7878
svgSlot.addEventListener('slotchange', () => {
7979
this.#cloneNodes.forEach((n) => {
8080
if (this.#svgContainer.contains(n)) {
81-
this.removeChild(n)
81+
this.#svgContainer.removeChild(n)
8282
}
8383
})
8484

8585
const svgNodes = svgSlot
8686
.assignedNodes()
8787
.filter((n) => n.nodeName === 'svg')
8888
this.#cloneNodes = svgNodes.map((n) => n.cloneNode(true))
89-
this.#cloneNodes.forEach((n) => {
90-
this.#svgContainer.append(n.cloneNode(true))
91-
})
89+
this.#cloneNodes.forEach((n) => this.#svgContainer.append(n))
9290
})
9391
}
9492

0 commit comments

Comments
 (0)