From efda964ddb8f396403ba7cb1987f77b84d984793 Mon Sep 17 00:00:00 2001 From: kay999 Date: Tue, 15 May 2018 14:13:39 +0200 Subject: [PATCH] Updated documentation for eventlisteners --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index d23b631..9905804 100644 --- a/README.md +++ b/README.md @@ -454,6 +454,14 @@ h('div', [ ]); ``` +Each handler is called not only with the given arguments but also with the current event and vnode appended to the argument list. It also supports using multiple listeners per event by specifying an array of handlers: +```javascript +stopPropagation = function(ev) { ev.stopPropagation() } +sendValue = function(func, ev, vnode) { func(vnode.elm.value) } + +h('a', { on:{ click:[[sendValue, console.log], stopPropagation] } }); +``` + Snabbdom allows swapping event handlers between renders. This happens without actually touching the event handlers attached to the DOM.