UNPKG

perlite

Version:

[![perlite logo](/docs/logo.svg)]()

13 lines (10 loc) 389 B
import { directive, EventPart } from 'lit-html'; export const capture = directive((handleEvent) => (part) => { if (!(part instanceof EventPart)) { throw new Error('"capture" directive can only be used in event listeners'); } part.setValue(typeof handleEvent === 'object' ? { ...handleEvent, capture: true } : { handleEvent, capture: true } ); });