Socket
Socket
Sign inDemoInstall

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.2 to 0.1.3

2

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

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

@@ -115,4 +115,9 @@ # Snabbdom

### Class module
### The class module
The class module provides an easy way to dynamically toggle classes on
elements. It expects an object in the `class` data property. The object should
map class names to booleans that indicates whether or not the class should stay
or go on the VNode.
```javascript

@@ -122,4 +127,6 @@ h('a', {class: {active: true, selected: false}}, 'Toggle');

### Props module
### The props module
Allows you to set properties on DOM elements.
```javascript

@@ -129,5 +136,50 @@ h('a', {props: {href: '/foo'}, 'Go to Foo');

### Style module
### The style module
The style module is for making your HTML look slick and animate smoothly. At
it's core it allows you to set CSS properties on elements.
```javascript
h('span', {
style: {border: '1px solid #bada55', color: '#c0ffee', fontWeight: 'bold'}
}, 'Say my name, and every colour illuminates');
```
#### Delayed properties
You can specify properties as being delayed. Whenver these properties change
the change is not applied until after the next frame.
```javascript
h('span', {
style: {opacity: '0', transitionDuration: 'opacity 1s', delayed: {opacity: '1'}}
}, 'Imma fade right in!');
```
#### Set properties on `remove`
```javascript
h('span', {
style: {opacity: '1', transitionDuration: 'opacity 1s',
remove: {opacity: '1'}}
}, 'It\'s better to fade out than to burn away');
```
#### Set properties on `destroy`
```javascript
h('span', {
style: {opacity: '1', transitionDuration: 'opacity 1s',
destroy: {opacity: '1'}}
}, 'It\'s better to fade out than to burn away');
```
#### Destroy properties
### Eventlisteners module
#### Destroy properties
### Eventlisteners module

@@ -84,11 +84,4 @@ // jshint newcap: false

function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
if (isUndef(before)) {
for (; startIdx <= endIdx; ++startIdx) {
parentElm.appendChild(createElm(vnodes[startIdx]));
}
} else {
var elm = before.elm;
for (; startIdx <= endIdx; ++startIdx) {
parentElm.insertBefore(createElm(vnodes[startIdx]), elm);
}
for (; startIdx <= endIdx; ++startIdx) {
parentElm.insertBefore(createElm(vnodes[startIdx]), before);
}

@@ -133,3 +126,3 @@ }

var newEndVnode = newCh[newEndIdx];
var oldKeyToIdx, idxInOld, elmToMove;
var oldKeyToIdx, idxInOld, elmToMove, before;

@@ -174,4 +167,8 @@ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {

}
if (oldStartIdx > oldEndIdx) addVnodes(parentElm, oldStartVnode, newCh, newStartIdx, newEndIdx);
else if (newStartIdx > newEndIdx) removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
if (oldStartIdx > oldEndIdx) {
before = isUndef(newCh[newEndIdx+1]) ? null : newCh[newEndIdx+1].elm;
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
} else if (newStartIdx > newEndIdx) {
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
}
}

@@ -197,3 +194,3 @@

} else if (!isUndef(ch)) {
addVnodes(elm, undefined, ch, 0, ch.length - 1);
addVnodes(elm, null, ch, 0, ch.length - 1);
} else if (!isUndef(oldCh)) {

@@ -203,3 +200,3 @@ removeVnodes(elm, oldCh, 0, oldCh.length - 1);

} else if (oldVnode.text !== vnode.text) {
elm.childNodes[0].nodeValue = vnode.text;
elm.textContent = vnode.text;
}

@@ -206,0 +203,0 @@ return vnode;

@@ -115,3 +115,9 @@ var assert = require('assert');

describe('updating children with keys', function() {
function spanNum(n) { return h('span', {key: n}, n.toString()); }
function spanNum(n) {
if (typeof n === 'string') {
return h('span', {}, n);
} else {
return h('span', {key: n}, n.toString());
}
}
describe('addition of elements', function() {

@@ -286,2 +292,12 @@ it('appends elements', function() {

});
it('moves a key in non-keyed nodes with a size up', function() {
var vnode1 = h('span', [1, 'a', 'b', 'c'].map(spanNum));
var vnode2 = h('span', ['d', 'a', 'b', 'c', 1, 'e'].map(spanNum));
patch(vnode0, vnode1);
assert.equal(elm.childNodes.length, 4);
assert.equal(elm.textContent, '1abc');
patch(vnode1, vnode2);
assert.equal(elm.childNodes.length, 6);
assert.equal(elm.textContent, 'dabc1e');
});
});

@@ -349,2 +365,10 @@ it('reverses elements', function() {

});
it('handles changing text children', function() {
var vnode1 = h('div', ['Text', h('span', 'Span')]);
var vnode2 = h('div', ['Text2', h('span', 'Span')]);
patch(vnode0, vnode1);
assert.equal(elm.childNodes[0].textContent, 'Text');
patch(vnode1, vnode2);
assert.equal(elm.childNodes[0].textContent, 'Text2');
});
it('prepends element', function() {

@@ -351,0 +375,0 @@ var vnode1 = h('div', [h('span', 'World')]);

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