Skip to content

Commit 7e3982c

Browse files
🐎 Reduce the number of unnecessary calls
1 parent 64b596e commit 7e3982c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/class/HTMLCodeBlockElement.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ export default class HTMLCodeBlockElement extends HTMLElement {
160160
return;
161161
}
162162

163+
this.#observer.disconnect();
164+
163165
const src = (() => {
164166
if (/[^\n]\n$/.test(this.#value)) {
165167
return `${this.#value}\n`;
@@ -207,6 +209,16 @@ export default class HTMLCodeBlockElement extends HTMLElement {
207209
}
208210

209211
set label(value: any) {
212+
if (
213+
this.#label === value ||
214+
(
215+
this.#label === '' &&
216+
value === null
217+
)
218+
) {
219+
return;
220+
}
221+
210222
if (value === null) {
211223
this.#label = '';
212224
this.removeAttribute('label');
@@ -227,6 +239,16 @@ export default class HTMLCodeBlockElement extends HTMLElement {
227239
}
228240

229241
set language(value: any) {
242+
if (
243+
this.#language === value ||
244+
(
245+
this.#language === '' &&
246+
value === null
247+
)
248+
) {
249+
return;
250+
}
251+
230252
if (value === null) {
231253
this.#language = '';
232254
this.removeAttribute('language');
@@ -247,6 +269,10 @@ export default class HTMLCodeBlockElement extends HTMLElement {
247269
}
248270

249271
set controls(value: boolean) {
272+
if (this.#controls === value) {
273+
return;
274+
}
275+
250276
this.#controls = value;
251277

252278
if (this.#controls) {

0 commit comments

Comments
 (0)