Stops propagation and prevents the default handler of the given event.

Type signature

(event: {
    preventDefault: () => void;
    stopPropagation: () => void;
}) => boolean

Examples

const event = {
  preventDefault: () =>
    console.log("preventDefault"),
  stopPropagation: () =>
    console.log("stopPropagation"),
};

cancel(event);
Try in REPL

Questions

  • How to stop event propagation and prevent default at once?

TypeScript sourceJavaScript source