avoid mutating DOM unnecessarily in toggleDataset()
This commit is contained in:
parent
598735fc7b
commit
54427c498d
|
@ -337,10 +337,11 @@ async function showSpinner(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleDataset(el, prop, state) {
|
function toggleDataset(el, prop, state) {
|
||||||
|
const wasEnabled = el.dataset[prop] != null; // avoids mutating DOM unnecessarily
|
||||||
if (state) {
|
if (state) {
|
||||||
el.dataset[prop] = '';
|
if (!wasEnabled) el.dataset[prop] = '';
|
||||||
} else {
|
} else {
|
||||||
delete el.dataset[prop];
|
if (wasEnabled) delete el.dataset[prop];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user