vue-lynx / withModifiers

Function: withModifiers()

function withModifiers(fn, modifiers): (...args) => unknown

Wraps an event handler with Lynx event modifiers.

Supported modifiers:

  • .once — handler is invoked at most once; subsequent events are ignored
  • .stop — registers the event as catchEvent (native Lynx stop-propagation) and also calls event.stopPropagation() for DOM environments
  • .prevent — accepted for code portability; no-op on Lynx (no browser default actions exist)
  • .self — skips the handler unless the event target is the listener element

The wrapped function is cached on fn._withMods keyed by the modifier string so that stable function references survive re-renders.

.stop sets _lynxCatch = true on the wrapper so that patchProp can register the event as catchEvent — the native Lynx mechanism for stopping event bubbling. Calling stopPropagation() at the JS level alone is not sufficient because native Lynx bubbling is decided before JS handlers run.

Parameters

ParameterType
fn(...args) => unknown
modifiersstring[]

Returns

Function

Parameters

ParameterType
...argsunknown[]

Returns

unknown

Defined in

packages/vue-lynx/runtime/src/index.ts:1114