Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

attodom

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attodom - npm Package Compare versions

Comparing version 0.8.2 to 0.8.3

4

CHANGELOG.md

@@ -9,2 +9,6 @@ # Change Log

## [0.8.3] - 2018-09-07
### Added
- getKey as a string instead of Function only
## [0.8.0] - 2018-08-26

@@ -11,0 +15,0 @@ ### Removed

10

list.js
/**
* @param {!Function} make
* @param {Function} [getK]
* @param {Function|string} [getK]
* @return {Node}
*/
module.exports = function(make, getK) {
var kin = document.createComment('[')
var kin = document.createComment('['),
isFunc = getK == null || getK.constructor === Function
//@ts-ignore

@@ -13,3 +14,4 @@ kin.update = updateList

make: make,
getK: getK || getKey,
keyF: isFunc,
getK: isFunc ? getK || getKey : getK,
kids: Object.create(null),

@@ -50,3 +52,3 @@ tail: document.createComment(']')

for (var i = 0; i < arr.length; ++i) {
var key = list.getK(arr[i], i, arr),
var key = list.keyF ? list.getK(arr[i], i, arr) : arr[i][list.getK],
kid = list.kids[key]

@@ -53,0 +55,0 @@ //create or update kid

{
"name": "attodom",
"version": "0.8.2",
"version": "0.8.3",
"main": "./index.js",

@@ -5,0 +5,0 @@ "description": "yet another small DOM component library",

@@ -57,5 +57,9 @@ # attodom

* `nodeFactory: function(value:* [, key:* [, object:*]]): Node`
`getKey: function([*], [number], [Array]): string`
* `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).
`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)`
A list can't contain another list

@@ -62,0 +66,0 @@

@@ -33,2 +33,3 @@ /* global document */

})
ct('list mounted', function() {

@@ -48,2 +49,3 @@ var list = ls(upperKid),

})
ct('list mounted with next', function() {

@@ -63,3 +65,4 @@ var list = ls(upperKid),

})
ct('list keyed', function() {
ct('list function key getter', function() {
var kin = el('h0', ls(

@@ -80,2 +83,20 @@ function(o) { return el('p', o.v, {update: function(v) { this.textContent = v.v.toUpperCase() }}) },

})
ct('list string key getter', function() {
var kin = el('h0', ls(
function(o) { return el('p', o.v, {update: function(v) { this.textContent = v.v.toUpperCase() }}) },
'k'
), {update: updateChildren})
ct('===', toString(kin.childNodes), '')
//@ts-ignore
kin.update([{k: 'a', v:'a'}, {k: 'b', v:'b'}, {k: 'c', v:'c'}])
ct('===', toString(kin.childNodes), 'abc')
//@ts-ignore
kin.update([{k: 'c', v:'c'}, {k: 'd', v:'d'}, {k: 'e', v:'e'}, ])
ct('===', toString(kin.childNodes), 'Cde')
//@ts-ignore
kin.update([{k: 'a', v:'a'}, {k: 'b', v:'b'}, {k: 'c', v:'c'}])
ct('===', toString(kin.childNodes), 'abC')
})
ct('list multiple', function() {

@@ -82,0 +103,0 @@ var kin = el('div', ls(upperKid), '$', ls(upperKid), ls(upperKid), {update: updateChildren})

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