Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vdom-to-html

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vdom-to-html

Turn virtual-dom nodes into HTML

  • 2.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.5K
increased by29.3%
Maintainers
1
Weekly downloads
 
Created
Source

vdom-to-html

NPM version Github release Build status Test coverage Dependency Status License

Turn virtual-dom nodes into HTML

Installation

npm install --save vdom-to-html

Usage

var VNode = require('virtual-dom/vnode/vnode');
var toHTML = require('vdom-to-html');

toHTML(new VNode('input', { className: 'name', type: 'text' }));
// => '<input class="name" type="text">'

Special case for Widgets

Widgets are used to take control of the patching process, allowing the user to create stateful components, control sub-tree rendering, and hook into element removal. Documentation is available here.

Widgets are given an opportunity to provide a vdom representation through an optional render method. If the render method is not found an empty string will be used instead.

var Widget = function(text) {
  this.text = text;
}
Widget.prototype.type = 'Widget';
// provide a vdom representation of the widget
Widget.prototype.render = function() {
  return new VNode('span', null, [new VText(this.text)]);
};
// other widget prototype methods would be implemented

toHTML(new Widget('hello'));
// => '<span>hello</span>'

FAQs

Package last updated on 22 Jan 2017

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