Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "snabbdom", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A virtual DOM library with focus on simplicity, modularity, powerful features and performance.", | ||
@@ -5,0 +5,0 @@ "main": "snabbdom.js", |
@@ -111,3 +111,4 @@ # Snabbdom | ||
It is recommended that you use `snabbdom/h` to create VNodes. `h` accepts a a | ||
tag/selector as a string, an optional data object and an option string or array of children. | ||
tag/selector as a string, an optional data object and an optional string or | ||
array of children. | ||
@@ -124,3 +125,2 @@ ```javascript | ||
#### Overview | ||
@@ -140,2 +140,17 @@ | ||
#### Usage | ||
To use hooks, pass them as an object to `hook` field of the data object | ||
argument. | ||
```javascript | ||
h('div.row', { | ||
key: movie.rank, | ||
hook: { | ||
insert: (vnode) => { movie.elmHeight = vnode.elm.offsetHeight; } | ||
} | ||
}); | ||
``` | ||
## Modules documentation | ||
@@ -142,0 +157,0 @@ |
@@ -211,7 +211,14 @@ // jshint newcap: false | ||
insertedVnodeQueue = []; | ||
for (i = 0; i < cbs.pre.length; ++i) cbs.pre[i](); | ||
if (oldVnode instanceof Element) { | ||
oldVnode = emptyNodeAt(oldVnode); | ||
if (oldVnode.parentElement !== null) { | ||
createElm(vnode); | ||
oldVnode.parentElement.replaceChild(vnode.elm, oldVnode); | ||
} else { | ||
oldVnode = emptyNodeAt(oldVnode); | ||
patchVnode(oldVnode, vnode); | ||
} | ||
} else { | ||
patchVnode(oldVnode, vnode); | ||
} | ||
for (i = 0; i < cbs.pre.length; ++i) cbs.pre[i](); | ||
patchVnode(oldVnode, vnode); | ||
for (i = 0; i < insertedVnodeQueue.length; ++i) { | ||
@@ -218,0 +225,0 @@ insertedVnodeQueue[i].data.hook.insert(insertedVnodeQueue[i]); |
@@ -63,2 +63,10 @@ var assert = require('assert'); | ||
}); | ||
it('has different tag and id', function() { | ||
var elm = document.createElement('div'); | ||
vnode0.appendChild(elm); | ||
var vnode1 = h('span#id'); | ||
patch(elm, vnode1); | ||
assert.equal(vnode1.elm.tagName, 'SPAN'); | ||
assert.equal(vnode1.elm.id, 'id'); | ||
}); | ||
it('has id', function() { | ||
@@ -65,0 +73,0 @@ patch(vnode0, h('div', [h('div#unique')])); |
Sorry, the diff of this file is too big to display
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
471676
9649
255