From 5c32eb73b34af6550804b1858291c2cf6dbcb741 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Mon, 25 Jul 2022 18:29:29 +0800 Subject: [PATCH] style: remove empty element. --- main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.js b/main.js index fa8a0d2..7fcc6ac 100644 --- a/main.js +++ b/main.js @@ -137,6 +137,9 @@ class DarkMode extends HTMLElement { _changeContent() { this.icon.textContent = this.mode === LIGHT ? '🌒' : '🌞'; this.text.textContent = this.mode === LIGHT ? this.getAttribute(DARK) : this.getAttribute(LIGHT); + if (!this.text.textContent && this.text.parentElement && this.text) { + this.text.parentElement.removeChild(this.text) + } } _initializeDOM() { var shadow = this.attachShadow({ mode: 'open' });