Socket
Book a DemoInstallSign in
Socket

to-vdom

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-vdom

Convert given HTML/DOM into Virtual DOM object

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

virtual-html

Convert given HTML/DOM into Virtual DOM object

Install

$ npm install to-vdom

Usage

Async:

var html = '<div class="foo bar" style="color: red; background: yellow;" data-yo="123">yo</div>';
// ^ Could be a DOM object as well.

var virtual = require('to-vdom')

virtual(html, function (error, dom) {
  if (error) throw error

  dom.tagName
  // => 'div'

  dom.children[0].text
  // => 'yo'

  dom.properties.dataset.yo
  // => 123
})

Sync:

var html = '<div class="foo bar" style="color: red; background: yellow;" data-yo="123">yo</div>';

var virtual = require('to-vdom')

// synchronous interface
var dom = virtual(html)

dom.tagName
// => 'div'

dom.children[0].text
// => 'yo'

dom.properties.dataset.yo
// => 123

Keywords

html

FAQs

Package last updated on 20 Nov 2016

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