Skip to content

yoshuawuyts/virtual-html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

virtual-html

Convert given HTML into Virtual DOM object

Install

$ npm install virtual-html

Usage

Async:

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

var virtual = require('virtual-html')

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('virtual-html')

// synchronous interface
var dom = virtual(html)

dom.tagName
// => 'div'

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

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

About

🌴 HTML → virtual-dom

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •