Comparing version 0.5.2 to 0.5.3
{ | ||
"name": "snabbdom", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "A virtual DOM library with focus on simplicity, modularity, powerful features and performance.", | ||
@@ -5,0 +5,0 @@ "main": "snabbdom.js", |
@@ -42,3 +42,5 @@ // jshint newcap: false | ||
function emptyNodeAt(elm) { | ||
return VNode(api.tagName(elm).toLowerCase(), {}, [], undefined, elm); | ||
var id = elm.id ? '#' + elm.id : ''; | ||
var c = elm.className ? '.' + elm.className.split(' ').join('.') : ''; | ||
return VNode(api.tagName(elm).toLowerCase() + id + c, {}, [], undefined, elm); | ||
} | ||
@@ -45,0 +47,0 @@ |
@@ -139,2 +139,13 @@ var assert = require('assert'); | ||
}); | ||
it('is a patch of the root element', function () { | ||
var elmWithIdAndClass = document.createElement('div'); | ||
elmWithIdAndClass.id = 'id'; | ||
elmWithIdAndClass.className = 'class'; | ||
var vnode1 = h('div#id.class', [h('span', 'Hi')]); | ||
elm = patch(elmWithIdAndClass, vnode1).elm; | ||
assert.strictEqual(elm, elmWithIdAndClass); | ||
assert.equal(elm.tagName, 'DIV'); | ||
assert.equal(elm.id, 'id'); | ||
assert.equal(elm.className, 'class'); | ||
}); | ||
}); | ||
@@ -674,3 +685,3 @@ describe('pathing an element', function() { | ||
var vnode1 = h('div', [h('a', {hook: {remove: function(_, rm) { rm3 = rm; }}})]); | ||
var vnode2 = h('div', []); | ||
var vnode2 = h('div', []); | ||
elm = patch(vnode0, vnode1).elm; | ||
@@ -691,3 +702,3 @@ assert.equal(elm.children.length, 1); | ||
var vnode0 = document.createElement('div'); | ||
parent.appendChild(vnode0); | ||
parent.appendChild(vnode0); | ||
function cb(vnode, rm) { | ||
@@ -731,3 +742,3 @@ result.push(vnode); | ||
]); | ||
var vnode2 = h('div'); | ||
var vnode2 = h('div'); | ||
patch(vnode0, vnode1); | ||
@@ -759,3 +770,3 @@ patch(vnode1, vnode2); | ||
]); | ||
var vnode2 = h('div'); | ||
var vnode2 = h('div'); | ||
patch(vnode0, vnode1); | ||
@@ -778,3 +789,3 @@ patch(vnode1, vnode2); | ||
]); | ||
var vnode2 = h('div'); | ||
var vnode2 = h('div'); | ||
patch(vnode0, vnode1); | ||
@@ -799,3 +810,3 @@ patch(vnode1, vnode2); | ||
]); | ||
var vnode2 = h('div'); | ||
var vnode2 = h('div'); | ||
patch(vnode0, vnode1); | ||
@@ -802,0 +813,0 @@ patch(vnode1, vnode2); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
516232
9541