mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: remove unused event helper
This commit is contained in:
parent
c2f4165d0f
commit
5ccd2129b9
@ -1,47 +1,3 @@
|
|||||||
import { inBrowser } from '..';
|
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-mutable-exports
|
|
||||||
export let supportsPassive = false;
|
|
||||||
|
|
||||||
if (inBrowser) {
|
|
||||||
try {
|
|
||||||
const opts = {};
|
|
||||||
Object.defineProperty(opts, 'passive', {
|
|
||||||
// eslint-disable-next-line getter-return
|
|
||||||
get() {
|
|
||||||
supportsPassive = true;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
window.addEventListener('test-passive', null as any, opts);
|
|
||||||
// eslint-disable-next-line no-empty
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function on(
|
|
||||||
target: EventTarget,
|
|
||||||
event: string,
|
|
||||||
handler: EventListenerOrEventListenerObject,
|
|
||||||
passive = false
|
|
||||||
) {
|
|
||||||
if (inBrowser) {
|
|
||||||
target.addEventListener(
|
|
||||||
event,
|
|
||||||
handler,
|
|
||||||
supportsPassive ? { capture: false, passive } : false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function off(
|
|
||||||
target: EventTarget,
|
|
||||||
event: string,
|
|
||||||
handler: EventListenerOrEventListenerObject
|
|
||||||
) {
|
|
||||||
if (inBrowser) {
|
|
||||||
target.removeEventListener(event, handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function stopPropagation(event: Event) {
|
export function stopPropagation(event: Event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user