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

yet another small DOM component library

  • 0.9.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

attodom

yet another experimental small DOM component library, < 1kb

WhyAPILicense

Why

  • experimenting on different APIs to find the minimal helpers required for
    • dynamic nodes, elements and lists
    • one way data flow from root component to child nodes

Features

  • multiple dynamic lists within the same parent
  • svg and namespace support
  • no virtual DOM, all operations are done on actual nodes
  • < 1kb gzip, no dependencies
  • Designed for phones and/or older browsers:
    • very low memory requirement
    • no transpilation required

Limitations

  • strictly DOM element creation and manipulations (no router, no store)

API

Elements and Nodes (hyperscript)

  • el(tagName [, attributes [,children ]] ): HTMLElement
  • svg(tagName [, attributes [,children ]] ): SVGElement
  • text(content [, properties ]] ): TextNode

where

  • attributes: {name: value, update: updateFunction}
  • children: {number|string|Node|Array<children>}
  • updateFunction: (this:Node, value:* [, key:* [, object:*]]): void

Helper Function

  • updateChildren: function(this:ParentNode, value:* [, key:* [, object:*]]): void Updates all children nodes of a parent node

Lists

  • list([getKey, ]nodeFactory): CommentNode

where

  • getKey: string | function([*], [number], [Array]): string
  • nodeFactory: function(value:* [, key:* [, object:*]]): Node

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) (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))

A list can't contain another list

var ol = el('ol',
  list((v, i) => el('li', i + ':' + v)),
  {update: updateChildren}
)
ol.update(['a', 'b'])
//=> <ol><#comment><li>1:a</li><li>2:b</li><#comment></ol>

License

MIT © Hugo Villeneuve

Keywords

FAQs

Package last updated on 08 Sep 2018

Did you know?

Socket

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.

Install

Related posts

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