Skip to content

Commit

Permalink
Optimize event handlers for performance and filesize
Browse files Browse the repository at this point in the history
  • Loading branch information
replete committed Sep 20, 2024
1 parent 8d42669 commit fd84103
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 71 deletions.
11 changes: 5 additions & 6 deletions dist/biscuitman-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,12 @@
saveConsents(false);
}
};
ui.onchange = function (e) {
if (!e.target.dataset.s) return;
e.target.parentElement.classList.toggle('checked', e.target.checked);
};
dialog = ui.querySelector('dialog');
if (o.dialogPolyfill && !dialog.close || !dialog.showModal) loadDialogPolyfill(dialog);
if (o.dialogPolyfill && !dialog.close) loadDialogPolyfill(dialog);
dialog.onclose = function () {
return dispatch('close');
};
Expand All @@ -717,11 +721,6 @@
return e.key === 'Escape' ? e.preventDefault() : null;
};
}
ui.querySelectorAll('[data-s]').forEach(function (checkbox) {
return checkbox.addEventListener('change', function (e) {
checkbox.parentElement.classList.toggle('checked', e.target.checked);
});
});
d.body.appendChild(ui);
w.addEventListener('resize', updateBannerHeight);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/biscuitman-legacy.min.js

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions dist/biscuitman-legacy.withcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,12 @@
saveConsents(false);
}
};
ui.onchange = function (e) {
if (!e.target.dataset.s) return;
e.target.parentElement.classList.toggle('checked', e.target.checked);
};
dialog = ui.querySelector('dialog');
if (o.dialogPolyfill && !dialog.close || !dialog.showModal) loadDialogPolyfill(dialog);
if (o.dialogPolyfill && !dialog.close) loadDialogPolyfill(dialog);
dialog.onclose = function () {
return dispatch('close');
};
Expand All @@ -717,11 +721,6 @@
return e.key === 'Escape' ? e.preventDefault() : null;
};
}
ui.querySelectorAll('[data-s]').forEach(function (checkbox) {
return checkbox.addEventListener('change', function (e) {
checkbox.parentElement.classList.toggle('checked', e.target.checked);
});
});
d.body.appendChild(ui);
w.addEventListener('resize', updateBannerHeight);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/biscuitman-legacy.withcss.min.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions dist/biscuitman.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,17 @@
saveConsents(false);
}
};
ui.onchange = (e)=>{
if (!e.target.dataset.s) return;
e.target.parentElement.classList.toggle('checked', e.target.checked);
};
dialog = ui.querySelector('dialog');
if (o.dialogPolyfill && !dialog.close || !dialog.showModal) loadDialogPolyfill(dialog);
if (o.dialogPolyfill && !dialog.close) loadDialogPolyfill(dialog);
dialog.onclose = ()=>dispatch('close');
if (o.force) {
dialog.oncancel = (e)=>e.preventDefault();
dialog.onkeydown = (e)=>e.key === 'Escape' ? e.preventDefault() : null;
}
ui.querySelectorAll('[data-s]').forEach((checkbox)=>checkbox.addEventListener('change', (e)=>{
checkbox.parentElement.classList.toggle('checked', e.target.checked);
}));
d.body.appendChild(ui);
w.addEventListener('resize', updateBannerHeight);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/biscuitman.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions dist/biscuitman.withcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,17 @@
saveConsents(false);
}
};
ui.onchange = (e)=>{
if (!e.target.dataset.s) return;
e.target.parentElement.classList.toggle('checked', e.target.checked);
};
dialog = ui.querySelector('dialog');
if (o.dialogPolyfill && !dialog.close || !dialog.showModal) loadDialogPolyfill(dialog);
if (o.dialogPolyfill && !dialog.close) loadDialogPolyfill(dialog);
dialog.onclose = ()=>dispatch('close');
if (o.force) {
dialog.oncancel = (e)=>e.preventDefault();
dialog.onkeydown = (e)=>e.key === 'Escape' ? e.preventDefault() : null;
}
ui.querySelectorAll('[data-s]').forEach((checkbox)=>checkbox.addEventListener('change', (e)=>{
checkbox.parentElement.classList.toggle('checked', e.target.checked);
}));
d.body.appendChild(ui);
w.addEventListener('resize', updateBannerHeight);
}
Expand Down
Loading

0 comments on commit fd84103

Please sign in to comment.