Security News
Supply Chain Attack Detected in @solana/web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
yet another small DOM component library, <2kb
• Example • Why • API • License
var {el, list} = require('attodom'),
Store = require('./Store'), // any user store will do
{ic_remove, ic_add} = require('./icons') //any pre-defined component
var store = new Store([])
var table = el('table').append(
el('caption').a('class', 'f4').text('table example with...'),
el('tbody').append(
list(function(rowKey) {
return el('tr').append(
el('td') //leading column with icon
.on('click', function() {store.delRow(rowKey) })
.child(ic_remove.cloneNode(true)),
list(function(colKey) {
return el('td') // data columns
.child(
el('input')
.set('update', function(v) { this.node.value = v })
.on('change', function() {store.set(this.node.value, [rowKey, colKey]) } )
)
})
)
}),
el('tr').append(
el('td')
.on('click', function() { store.addRow() } )
.child(ic_add)
)
)
)
.moveTo(D.body)
store.onchange = function() { table.update( store.get() ) }
store.set([
['icons', 'SVG icons'],
['keyed', 'keyed list'],
['store', 'data flow'],
['event', 'event listeners']
])
document API
for server use and/or testing (e.g. jsdom
)Components can be created with the functions el, elNS, svg, text, list, select and component
creating Element component
el(tagName): Component
elNS(nsURI, tagName): Component
svg(tagName): Component
component(element): Component
creating Node components (e.g. TextNode)
text(textContent): Component
component(node): Component
List (component with multiple or no nodes)
list(factory): Component
select(components): Component
Components have a number of chainable methods:
.c(key, val)
.p(key, val)
.a(key, val)
.append(node | number | string | Array | null, ...)
.on(name, callback)
to add, on(name, falsy)
to removeList
and Select
are special components representing a group of multiple nodes.
List
take a single factory that will be used to generate list of varying sizes and an optional argument to derive a unique key from individual records
list(factory)
to create dynamic indexed set of nodes based on the size of the array upon updateslist(factory, function(v) {return v.id}})
for a keyed list(key, val, index, array) => component
Select lists have predefined components that are used to conditionally display subsets on updates. The optional select function returns the selected keys to show on each updates
list({a: componentA, b: componentB}, function(v) {return v ? [a] : [b]})
lists can be stacked and nested with other components or lists.
component.node
: the associated DOM node or comment node anchor node for lists.moveTo(parent [,before])
: to move a component.remove()
: to remove a component from the DOM.update(...)
the function to trigger changes based on external data.updateChildren(..)
to pass update data down the tree.By default, update is set to text
for text components and updateChildren
for the other components.
For additional lifecycle behaviours, component methods can be wrapped (moveTo
, remove
). If the arity (number of arguments) of the custom action is greater than the that of the component method, the method will be passed as an argument for async behaviours
co.wrap('moveTo', function() { console.log('about to move') })
co.wrap('remove', function(cb) { setTimeout(cb) })
Wrapper actions are launched before the native method.
find(from [, test] [, until])
find a component within nodes or components and matching the test function. It parses nodes up and down following the html markup order.
find(document.body)
to get the first component in the documentfind(tableComponent, function(c) { return c.key === 5 } )
css(ruleText)
to insert a rule in the document for cases where an exported factory relies on a specific css rule that is not convenient or practical to include in a seperate css fileDocument can be injected as follow:
const config = require('attodom/config')
config.document = myDocumentObject
eg svgElements icons
) or component factory functions.List
and Select
can't be updated unless they have a parentNode or parent fragment to hold them together.
list(childFactory).moveTo(D.createDocumentFragment()).update()
[0.4.0] - 2017-06-04
.wrap
, .text
, .id
, .class
methods.set
=> .c
.set
=> .c
setWindow
=> config.document
FAQs
yet another small DOM component library
The npm package attodom receives a total of 0 weekly downloads. As such, attodom popularity was classified as not popular.
We found that attodom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.