Socket
Socket
Sign inDemoInstall

any-dom

Package Overview
Dependencies
33
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    any-dom

Consistent style for any virtual dom library


Version published
Weekly downloads
8
increased by300%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

any-dom

consistent API for any virtual dom library

Greenkeeper badge

Provides a consistent API for any virtual dom library. Now one can create libraries that are not bound to only a single virtual dom library implementation.

Idea

There are so many virtual dom libraries on the internet right now and all of them have different APIs to create or patch the DOM. This makes it awfully tough to remember the signature while using and deters developers to make frameworks/libraries that are Virtual DOM agnostic.

Any DOM aims to solve this problem but keeping the API simple and consistent. It abstracts the original patching function and provides a more simpler function that looks like this —

function patch (container: HTMLElement, vNode: VirtualNode) : void 

The patch function takes in two arguments — First is the real DOM element and second is Virtual DOM element and it returns nothing. Now we can pass the patch function as an argument to our framework/library and expect it to just work :-)

Usage

Simplified Imports


// Using react
import {patch, h} from 'any-dom/react'

// using snabbdom
import {patch, h} from 'any-dom/snabbdom'

// using preact
import {patch, h} from 'any-dom/preact'

Simplified CDN

<script src="https://unpkg.com/any-dom/react.js"></script>

<script >
  console.log(window.anydom.patch)
</script>

Usage inside the DOM


import {patch, h} from 'any-dom/react'

const element = (
  h('h1', [
    'Hello, World!!'
  ])
)

patch(
  document.getElementById('root'),
  element  
)

Supported Libraries

Wishlist

  • Add mode virtual dom libraries.
  • Add consistent Hyperscript helpers

Keywords

FAQs

Last updated on 13 Jan 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc