In my previous post about Bean I discussed in detail the work that has gone in to a v1 release and how it will differ from the v0.4 branch.
Bean version 1.0.0 has now been released, you can download it from the GitHub repository or you can fetch it from npm for your Ender builds.
Here's a quick summary of the changes, but for a more in-depth look you should refer to my previous post.
on() argument ordering: the new signature is now
.on(events[, selector], handlerFn), which will work on both Bean as a standalone library and when bundled in Ender. In Ender, the following aliases also pass through
on() so the same arguments work:
one() (which of course will only trigger once). Plus all the specific shortcuts such as
keyup() etc. although these methods have the first argument hardwired.
add() is left intact with the same argument ordering for standalone Bean and
delegate() has the same signature, the same as jQuery's equivalent.
off() is the new
remove() is still available in standalone Bean.
Bean attaches a single handler to the DOM for each event type on each element: as outlined above, Bean will iterate over all handlers for each triggered and (mostly) reuse the same Event object for each call.
Event.stopImmediatePropagation(): is available across all supported browsers, it will stop the processing of all handlers for the current event at the current element (i.e. the event will still bubble).
The selector engine argument to
add() is now completely removed: you used to have to pass a selector engine in as the last argument for delegated events. Now you must set it once at start-up with
setSelectorEngine(). This is automatically taken care of for you in an Ender build.
A duplicate-handler check is no longer performed when you add: performance testing showed that this was a massive slow-down and is simply not something that Bean should be responsible for. If you want to add the same handler twice then that's your business and responsibility.
Namespace matching for event
fire()ing now matches namespaces using an and instead of an
or: so for example, firing namespaces 'a.b' will fire any event with both 'a' and 'b' rather than either 'a' or 'b'. This is compatible with jQuery and is arguably a much more sensible and helpful way to deal with namespaces. You can find some discussion on this on GitHub.
Lots of internal improvements for speed, code size, etc..
There was one remaining question to be resolved—whether
Event.stop() would also trigger
Event.stopImmediatePropagation(). I've decided to not include it and leave it to the user to decide whether they want to prevent triggering of other listeners on the same event/element.
And that's it! Please give it a spin and open an issue on GitHub if you have any bugs to report or questions to be answered.