Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snabbdom

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snabbdom - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

17

modules/eventlisteners.js

@@ -7,2 +7,6 @@ var is = require('../is');

function fnInvoker(arr) {
return function(ev) { arr[0](ev); };
}
function updateEventListeners(oldVnode, vnode) {

@@ -16,7 +20,16 @@ var name, cur, old, elm = vnode.elm,

if (old === undefined) {
elm.addEventListener(name, is.array(cur) ? arrInvoker(cur) : cur);
} else if (is.array(old)) {
if (is.array(cur)) {
elm.addEventListener(name, arrInvoker(cur));
} else {
cur = [cur];
on[name] = cur;
elm.addEventListener(name, fnInvoker(cur));
}
} else if (old.length === 2) {
old[0] = cur[0]; // Deliberately modify old array since it's
old[1] = cur[1]; // captured in closure created with `arrInvoker`
on[name] = old;
} else {
old[0] = cur;
on[name] = old;
}

@@ -23,0 +36,0 @@ }

2

package.json
{
"name": "snabbdom",
"version": "0.1.4",
"version": "0.1.5",
"description": "A virtual DOM library with focus on simplicity, modularity, powerful features and performance.",

@@ -5,0 +5,0 @@ "main": "snabbdom.js",

@@ -5,3 +5,3 @@ # Snabbdom

# Table of contents
## Table of contents

@@ -15,3 +15,3 @@ * [Introduction](#introduction)

# Introduction
## Introduction

@@ -28,3 +28,3 @@ Snabbdom consists of an extremely simple, performant and extensible core that

# Features
## Features

@@ -46,3 +46,3 @@ * Core features

# Inline example
## Inline example

@@ -68,3 +68,3 @@ ```javascript

# Examples
## Examples

@@ -74,3 +74,3 @@ * [Animated reordering of elements](http://paldepind.github.io/snabbdom/examples/reorder-animation/)

# Core documentation
## Core documentation

@@ -80,3 +80,3 @@ The core of Snabbdom provides only the most essential functionality. It is

## `snabbdom.init`
### `snabbdom.init`

@@ -93,3 +93,3 @@ The core exposes only one single function `snabbdom.init`. `init` takes a list of

## `patch`
### `patch`

@@ -104,3 +104,3 @@ The `patch` function returned by `init` takes two arguments. The first is a DOM

## `snabbdom/h`
### `snabbdom/h`

@@ -118,6 +118,17 @@ It is recommended that you use `snabbdom/h` to create VNodes. `h` accepts a a

## Hooks
### Hooks
# Modules documentation
| Name | Triggered when | Arguments to callback |
| --------- | -------------- | --------------------- |
| `pre` | the patch process begins. | |
| `create` | a DOM element has been created based on a VNode. | `emptyVNode, createdVnode` |
| `insert` | an element has been inserted into the DOM. | `insertedVnode` |
| `patch` | an element is about to be patched. | `oldVnode, newVnode` |
| `update` | an element is being updated. | `oldVnode, newVnode` |
| `remove` | an element is directly being removed from the DOM. | `vnode, removeCallback` |
| `destroy` | an element is begin removed from the DOM or it's parent is. | `vnode` |
| `post` | the patch process is done. | |
## Modules documentation
This describes the core modules.

@@ -184,10 +195,24 @@

#### Destroy properties
### Eventlisteners module
The event listeners module gives powerful capabilities for attaching
event listeners.
#### Destroy properties
You can attach a function that will be called with the event object.
### Eventlisteners module
```javascript
function clickHandler(ev) { console.log('got clicked'); }
h('div', {on: {click: clickHandler}});
```
We can also use the array syntax to attach a function that will be
invoked with a constant value.
```javascript
function clickHandler(number) { console.log('button ' + number + ' was clicked!'); }
h('div', [
h('a', {on: {click: [clickHandler, 1]}}),
h('a', {on: {click: [clickHandler, 2]}}),
h('a', {on: {click: [clickHandler, 3]}}),
]);
```

@@ -74,3 +74,3 @@ // jshint newcap: false

if (!isUndef(i)) {
if (i.create) i.create(vnode);
if (i.create) i.create(emptyNode, vnode);
if (i.insert) insertedVnodeQueue.push(vnode);

@@ -77,0 +77,0 @@ }

@@ -421,12 +421,13 @@ var assert = require('assert');

//function clicked(ev) { result.push(ev); }
var vnode1 = h('div', {on: {click: function(ev) { result.push(ev); }}}, [
var vnode1 = h('div', {on: {click: function(ev) { result.push(1); }}}, [
h('a', 'Click my parent'),
]);
var vnode2 = h('div', {on: {click: function(ev) { result.push(ev); }}}, [
var vnode2 = h('div', {on: {click: function(ev) { result.push(2); }}}, [
h('a', 'Click my parent'),
]);
patch(vnode0, vnode1);
elm.click();
patch(vnode1, vnode2);
elm.click();
assert.equal(1, result.length);
assert.deepEqual(result, [1, 2]);
});

@@ -468,3 +469,3 @@ it('does calls handler for function in array', function() {

var result = [];
function cb(vnode) {
function cb(empty, vnode) {
assert(vnode.elm instanceof Element);

@@ -471,0 +472,0 @@ assert.equal(vnode.elm.children.length, 2);

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc