Comparing version 0.8.3 to 0.9.0
@@ -9,5 +9,5 @@ # Change Log | ||
## [0.8.3] - 2018-09-07 | ||
### Added | ||
- getKey as a string instead of Function only | ||
## [0.9.0] - 2018-09-08 | ||
### Changed | ||
- list arguments changed (order and type) | ||
@@ -14,0 +14,0 @@ ## [0.8.0] - 2018-08-26 |
15
list.js
/** | ||
* @param {!Function} make | ||
* @param {Function|string} [getK] | ||
* @param {!Function|!string} key | ||
* @param {Function} [factory] | ||
* @return {Node} | ||
*/ | ||
module.exports = function(make, getK) { | ||
var kin = document.createComment('['), | ||
isFunc = getK == null || getK.constructor === Function | ||
module.exports = function(key, factory) { | ||
var kin = document.createComment('[') | ||
//@ts-ignore | ||
@@ -13,5 +12,5 @@ kin.update = updateList | ||
kin._$lK = { | ||
make: make, | ||
keyF: isFunc, | ||
getK: isFunc ? getK || getKey : getK, | ||
make: factory || key, | ||
keyF: (factory ? key : getKey).constructor === Function, | ||
getK: factory ? key : getKey, | ||
kids: Object.create(null), | ||
@@ -18,0 +17,0 @@ tail: document.createComment(']') |
{ | ||
"name": "attodom", | ||
"version": "0.8.3", | ||
"version": "0.9.0", | ||
"main": "./index.js", | ||
@@ -5,0 +5,0 @@ "description": "yet another small DOM component library", |
@@ -53,12 +53,12 @@ # attodom | ||
* `list(nodeFactory [, getKey]): CommentNode` | ||
* `list([getKey, ]nodeFactory): CommentNode` | ||
where | ||
* `getKey: string | function([*], [number], [Array]): string` | ||
* `nodeFactory: function(value:* [, key:* [, object:*]]): Node` | ||
* `getKey: string | function([*], [number], [Array]): string` | ||
`list` creates a `Comment Node` that will be followed by a variable number of Nodes upon update with an array. | ||
* If `getKey` is not provided, the list is 'unkeyed' (ie the key is the index) | ||
* If `getKey` is a string, the key is `value[getKey]` | ||
* If `getKey` is a function, the key is `getKey(value, index, array)` | ||
* If `getKey` is not provided, the list is 'unkeyed' (ie the key is the index) (example: `list(factory)`) | ||
* If `getKey` is a string, the key is `value[getKey]` (example: `list('id', factory)`) | ||
* If `getKey` is a function, the key is `getKey(value, index, array)` (example: `list(v=>v.id, factory)`) | ||
@@ -65,0 +65,0 @@ A list can't contain another list |
@@ -9,5 +9,7 @@ /* global document */ | ||
ls = require('../').list, | ||
setText = require('../notes/set-text-content'), | ||
updateChildren = require('../').updateChildren | ||
updateChildren = require('../').updateChildren, | ||
setter = require('../setter') | ||
var setText = setter('textContent') | ||
function toString(nodes) { | ||
@@ -67,4 +69,4 @@ var str = '' | ||
var kin = el('h0', ls( | ||
function(o) { return el('p', o.v, {update: function(v) { this.textContent = v.v.toUpperCase() }}) }, | ||
function(o) { return o.k } | ||
function(o) { return o.k }, | ||
function(o) { return el('p', o.v, {update: function(v) { this.textContent = v.v.toUpperCase() }}) } | ||
), {update: updateChildren}) | ||
@@ -85,4 +87,4 @@ ct('===', toString(kin.childNodes), '') | ||
var kin = el('h0', ls( | ||
function(o) { return el('p', o.v, {update: function(v) { this.textContent = v.v.toUpperCase() }}) }, | ||
'k' | ||
'k', | ||
function(o) { return el('p', o.v, {update: function(v) { this.textContent = v.v.toUpperCase() }}) } | ||
), {update: updateChildren}) | ||
@@ -89,0 +91,0 @@ ct('===', toString(kin.childNodes), '') |
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
17767