Save bytes on `preventTabClose`
Opened this issue · 1 comments
milkbump commented
Sorry, I'm not on a device I can make a PR. A bit of bike-shedding to save bytes on preventTabClose
.
Something along these lines:
// preventTabClose.js
function handler(e) {
e.preventDefault();
return '';
}
export const preventTabClose = (_, enabled) => {
window[enabled
? "addEventListener"
: "removeEventListener"
]('beforeunload', handler)
return {
update: preventTabClose,
destroy: () => preventTabClose(_, false),
};
};
swyxio commented
am fine with it. need tests more than i need to save bytes rn haha