vtree-query

0.2.0 • Public • Published

vtree-query

Install

npm install --save-dev vtree-query

Example

= require 'zorium'
query = require 'vtree-query'
 
tree = z 'div''test'
= query(tree)
$('div').contents.should.be 'test'
 
tree =
  z 'div',
    z '.class',
      z '#id',
        z 'span',
          'abc'
        z 'span',
          'xyz'
 
= query(tree)
$$ = query.all(tree)
 
$('div .class #id span').contents.should.be 'abc'
$('span').contents.should.be 'abc'
 
$$('div .class #id span').length.should.be 2
$$('span').length.should.be 2
 
# Properties 
tree = z 'input'type: 'button'
= query tree
$('input').type.should.be 'button'
 
# Attributes 
tree = z 'div',
  z 'a'href: 'abc''aaa'
 
= query tree
$('a[href=abc]').contents.should.be 'aaa'

query(vtree, selector)

Returns first matching vNode, with a contents property This method supports currying

tree = z 'div''test'
= query(tree)
$('div').contents.should.be 'test'

query.all()

Returns all matching vNodes, with contents properties This method supports currying

tree = z 'div''test'
$$ = query.all(tree)
$$('div')[0].contents.should.be 'test'

Readme

Keywords

none

Package Sidebar

Install

npm i vtree-query

Weekly Downloads

3

Version

0.2.0

License

MIT

Last publish

Collaborators

  • zolmeister