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
import {D, element as el, list} from '../module'
import {Store} from './Store' // any user store will do
import {ic_remove, ic_add} from './icons'
var store = new Store([])
var table = el('table').child(
el('caption').class('f4').text('table example with...'),
el('tbody').child(
list(function(rowKey) {
return el('tr').child(
el('td') //leading column with icon
.on('click', function() {store.delRow(rowKey) })
.child(ic_remove),
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').child(
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']
])
supports different environments
require('attodom').element
import {element} from 'attodom'
attodom.element
)setWindow
belowTwo examples are available:
npm run example:table
: dynamic list, 1-way data flow, components, iconsnpm run example:transition
: select list, transitionsdocument API
for server use and/or testing (e.g. jsdom
)textContent
and nodeValue
DOM APIComponents can be created with the functions element, elementNS, svg, text, list, select and component
Element
element(tagName)
elementNS(nsURI, tagName)
svg(tagName)
component(element)
Node
text(textContent)
component(node)
fragment()
List (component with multiple or no nodes)
list(factory)
select(components)
Components have a number of chainable methods:
.set(key, val)
.p(key, val)
.wrap(name, function)
.text(key, val)
.a(key, val)
.id(string)
.class(string)
.child(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.
setWindow(window)
to set the window and document interface for testing or server use
setWindow((new JSDOM).window)
W
and D
reference to the window
ad document
interface for testing or server use
document.body === D.body
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 fileeg 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.[0.3.0] - 2017-06-04
.wrap
helper.a
short form for attributesFAQs
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.