Giter Club home page Giter Club logo

attodom's Introduction

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 with one way data flow from root component to child nodes

Features

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

Limitations

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

API

Elements and Nodes (hyperscript)

  • el(tagName|Element [, attributes [,children ]] ): HTMLElement
  • svg(tagName|Element [, attributes [,children ]] ): SVGElement

where

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

Synthetic Events

Synthetic events are used when the first letter of the event name is capitalised

  • regular event: el('h1', {onclick: handler}, 'click me')
  • synthetic event: el('h1', {onClick: handler}, 'click me')

Lists

  • list(parent:Node, factory, options): List

where

  • factory: function(value:* [, key:* [, object:*]]): Node
  • options.before: Node
  • options.after: Node
  • options.key: string | function([*], [number], [Array]): string
  • List: {parent, before, after, factory, key, map:{key:Node}, update}
  • list.update: function([*], [number], [Array]): List

list creates a List object with an update method that can update the parent children to match a data Array

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

License

MIT © Hugo Villeneuve

attodom's People

Contributors

hville avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.