Comparing version 0.5.1 to 0.5.2
@@ -111,5 +111,7 @@ var root = require('./root'), | ||
var key = list.getKey(arr[i], i, arr), | ||
comp = kids[key] = list.kids[key] || list.factory(arr[i], i, arr), | ||
item = comp.node | ||
if (comp.update) comp.update(arr[i], i, arr) | ||
comp = list.kids[key] | ||
if (!comp) comp = list.factory(arr[i], i, arr) | ||
else if (comp.update) comp.update(arr[i], i, arr) | ||
kids[key] = comp | ||
var item = comp.node | ||
@@ -116,0 +118,0 @@ if (!spot) node.appendChild(item) |
{ | ||
"name": "attodom", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"main": "./index.js", | ||
@@ -5,0 +5,0 @@ "description": "yet another small DOM component library", |
@@ -19,4 +19,4 @@ var ct = require('cotest'), | ||
function setText(t) { this.node.textContent = t } | ||
function childFactory() { | ||
return co(el('p', 'x'), {update: setText}) | ||
function childFactory(v) { | ||
return co(el('p', v), {update: setText}) | ||
} | ||
@@ -44,4 +44,4 @@ var comp = co(el('div'), '^', ls(childFactory), '$'), | ||
var comp = co(el('h0'), ls( | ||
function() { | ||
return co(el('p'), 'x', {update: function(v) { this.node.textContent = v.v; this.update = null }}) | ||
function(val) { | ||
return co(el('p', val.v), {update: function(v) { this.node.textContent = v.v }}) | ||
}, | ||
@@ -57,15 +57,9 @@ v => v.k | ||
comp.update([{ k: 'b', v: 'bb' }, { k: 1, v: 11 }]) | ||
ct('===', toString(elem.childNodes), 'b1', 'must use existing nodes') | ||
comp.update([{k: 'c', v:'c'}]) | ||
ct('===', toString(elem.childNodes), 'c') | ||
comp.update([{ k: 'b', v: 'bbb' }, { k: 'c', v: 'ccc' }, { k: 1, v: 111 }]) | ||
ct('===', toString(elem.childNodes), 'bbbc111', 're-creates removed nodes') | ||
}) | ||
ct('list - multiple', function() { | ||
function childFactory() { | ||
return co(el('p')) | ||
function childFactory(v) { | ||
return co(el('p', v)) | ||
} | ||
@@ -72,0 +66,0 @@ var comp = co(el('div'), ls(childFactory), ls(childFactory)), |
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
19258
502