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.3.0 to 0.3.1

5

modules/class.js

@@ -5,2 +5,7 @@ function updateClass(oldVnode, vnode) {

klass = vnode.data.class || {};
for (name in oldClass) {
if (!klass[name]) {
elm.classList.remove(name);
}
}
for (name in klass) {

@@ -7,0 +12,0 @@ cur = klass[name];

function updateProps(oldVnode, vnode) {
var key, cur, old, elm = vnode.elm,
oldProps = oldVnode.data.props || {}, props = vnode.data.props || {};
for (key in oldProps) {
if (!props[key]) {
delete elm[key];
}
}
for (key in props) {

@@ -5,0 +10,0 @@ cur = props[key];

@@ -13,2 +13,7 @@ var raf = (window && window.requestAnimationFrame) || setTimeout;

oldHasDel = 'delayed' in oldStyle;
for (name in oldStyle) {
if (!style[name]) {
elm.style[name] = '';
}
}
for (name in style) {

@@ -15,0 +20,0 @@ cur = style[name];

2

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

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

@@ -106,2 +106,6 @@ var assert = require('assert');

});
it('can create elements with props', function() {
patch(vnode0, h('a', {props: {src: 'http://localhost/'}}));
assert.equal(elm.src, 'http://localhost/');
});
});

@@ -127,2 +131,25 @@ describe('pathing an element', function() {

});
it('removes missing classes', function() {
var vnode1 = h('i', {class: {i: true, am: true, horse: true}});
var vnode2 = h('i', {class: {i: true, am: true}});
patch(vnode0, vnode1);
patch(vnode1, vnode2);
assert(elm.classList.contains('i'));
assert(elm.classList.contains('am'));
assert(!elm.classList.contains('horse'));
});
it('changes an elements props', function() {
var vnode1 = h('a', {props: {src: 'http://other/'}});
var vnode2 = h('a', {props: {src: 'http://localhost/'}});
patch(vnode0, vnode1);
patch(vnode1, vnode2);
assert.equal(elm.src, 'http://localhost/');
});
it('removes an elements props', function() {
var vnode1 = h('a', {props: {src: 'http://other/'}});
var vnode2 = h('a');
patch(vnode0, vnode1);
patch(vnode1, vnode2);
assert.equal(elm.src, undefined);
});
describe('updating children with keys', function() {

@@ -129,0 +156,0 @@ function spanNum(n) {

@@ -35,2 +35,24 @@ var assert = require('assert');

});
it('explicialy removes styles', function() {
var vnode1 = h('i', {style: {fontSize: '14px'}});
var vnode2 = h('i', {style: {fontSize: ''}});
var vnode3 = h('i', {style: {fontSize: '10px'}});
patch(vnode0, vnode1);
assert.equal(elm.style.fontSize, '14px');
patch(vnode1, vnode2);
assert.equal(elm.style.fontSize, '');
patch(vnode2, vnode3);
assert.equal(elm.style.fontSize, '10px');
});
it('implicially removes styles from element', function() {
var vnode1 = h('div', [h('i', {style: {fontSize: '14px'}})]);
var vnode2 = h('div', [h('i')]);
var vnode3 = h('div', [h('i', {style: {fontSize: '10px'}})]);
patch(vnode0, vnode1);
assert.equal(elm.firstChild.style.fontSize, '14px');
patch(vnode1, vnode2);
assert.equal(elm.firstChild.style.fontSize, '');
patch(vnode2, vnode3);
assert.equal(elm.firstChild.style.fontSize, '10px');
});
it('updates delayed styles in next frame', function() {

@@ -37,0 +59,0 @@ var patch = snabbdom.init([

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