All Projects β†’ talentlessguy β†’ vdom

talentlessguy / vdom

Licence: MIT license
Simple JavaScript Virtual DOM

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to vdom

Puddles
Tiny vdom app framework. Pure Redux. No boilerplate.
Stars: ✭ 24 (+41.18%)
Mutual labels:  virtual-dom, vdom
Wonders
🌈 Declarative JavaScript framework to build command-line applications.
Stars: ✭ 34 (+100%)
Mutual labels:  virtual-dom, vdom
Muve
Muve is a micro library for building interactive javascript applications.
Stars: ✭ 11 (-35.29%)
Mutual labels:  virtual-dom, vdom
Vhtml
Render JSX/Hyperscript to HTML strings, without VDOM 🌈
Stars: ✭ 556 (+3170.59%)
Mutual labels:  virtual-dom, vdom
Omi
Front End Cross-Frameworks Framework - ε‰η«―θ·¨ζ‘†ζžΆθ·¨εΉ³ε°ζ‘†ζžΆ
Stars: ✭ 12,153 (+71388.24%)
Mutual labels:  virtual-dom, vdom
Domvm
DOM ViewModel - A thin, fast, dependency-free vdom view layer
Stars: ✭ 581 (+3317.65%)
Mutual labels:  virtual-dom, vdom
Ng Vdom
(Developer Preview) A virtual-DOM extension for Angular, also work as React bridge.
Stars: ✭ 249 (+1364.71%)
Mutual labels:  virtual-dom, vdom
Preact
βš›οΈ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
Stars: ✭ 30,527 (+179470.59%)
Mutual labels:  virtual-dom, vdom
Neo
Create blazing fast multithreaded Web Apps
Stars: ✭ 1,219 (+7070.59%)
Mutual labels:  virtual-dom, vdom
Asm Dom Boilerplate
A simple boilerplate to start using asm-dom without configuration.
Stars: ✭ 49 (+188.24%)
Mutual labels:  virtual-dom, vdom
Ivi
πŸ”₯ Javascript (TypeScript) library for building web user interfaces
Stars: ✭ 445 (+2517.65%)
Mutual labels:  virtual-dom, vdom
Mithril.js
A JavaScript Framework for Building Brilliant Applications
Stars: ✭ 13,062 (+76735.29%)
Mutual labels:  virtual-dom, vdom
Lowlight
Virtual syntax highlighting for virtual DOMs and non-HTML things
Stars: ✭ 310 (+1723.53%)
Mutual labels:  virtual-dom, vdom
Backbone.vdomview
VirtualDOM-aware Backbone View
Stars: ✭ 23 (+35.29%)
Mutual labels:  virtual-dom, vdom
Refractor
Lightweight, robust, elegant virtual syntax highlighting using Prism
Stars: ✭ 291 (+1611.76%)
Mutual labels:  virtual-dom, vdom
Remark Vdom
plugin to compile Markdown to Virtual DOM
Stars: ✭ 44 (+158.82%)
Mutual labels:  virtual-dom, vdom
Val
VirtualDOM abstraction layer - give yourself better integration and full control over the DOM with any virtual DOM library that uses a Hyperscript-like API such as React and Preact.
Stars: ✭ 181 (+964.71%)
Mutual labels:  virtual-dom, vdom
Asm Dom
A minimal WebAssembly virtual DOM to build C++ SPA (Single page applications)
Stars: ✭ 2,604 (+15217.65%)
Mutual labels:  virtual-dom, vdom
core
Server side rendering with The Elm Architecture in Deno
Stars: ✭ 16 (-5.88%)
Mutual labels:  virtual-dom
purescript-outwatch
A functional and reactive UI framework based on Rx and VirtualDom
Stars: ✭ 33 (+94.12%)
Mutual labels:  vdom

vdom

Simple JavaScript Virtual DOM. Compatible with htm.

Codacy Badge

Install

# npm
npm i simple-vdom
# pnpm
pnpm i simple-vdom
# yarn
yarn add simple-vdom

Example

Try it yourself

To build the example, clone the repository and write this to command line:

pnpm example

It will build the example. Then, launch a server for example directory. For example:

serve -s example -p 3000

And open it in a browser.

Code

import { h, render, diff } from 'simple-vdom'
import htm from 'htm'

const html = htm.bind(h)

// Create App component with a prop "counter"
let App = (counter) => html`<p style="${{ fontSize: counter * 2 + 'px' }}">
  <span>${counter}</span>
</p>`

// Return component with passed prop
let AppWithProps = App(0)

// Mount first state of app to container
let mount = render(AppWithProps, document.getElementById('app'))

setInterval(() => {
  // Generate random number
  const newCounter = parseInt(Math.random() * 10)

  // Return new state of app with new prop
  const newApp = App(newCounter)

  // Check for changes and collect patches
  const patch = diff(AppWithProps, newApp)

  // Replace old app with new one
  AppWithProps = newApp

  // Mount patched app
  mount = patch(mount)

  // Replace element
  document.getElementById('app').firstChild.replaceWith(patch(mount))
}, 1000)

API

h

A hyperscript function that returns vnode (a plain object)

const el = h('h1', null, 'Hello')

console.log(el)

/*
{
  tag: 'h1',
  props: null,
  children: 'Hello'
}
*/

renderNode

Renders objects created by h to DOM nodes

const vnode = renderNode(html`<h1>Hello World</h1>`)

console.log(vnode)

/*
[Object HTMLElement]
*/

render

Append vnode to DOM container.

render(html`<h1>Hello World</h1>`, document.getElementById('app'))

diff

Check for differences in DOM and return patches.

const App = html`<p>Hi</p>`

const newApp = html`<p>Hello</p>`

const dom = diff(App, newApp)

render(dom, document.getElementById('app'))

License

MIT Β© v1rtl

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].