vtree-query
Install
npm install --save-dev vtree-query
Example
z = require 'zorium'query = require 'vtree-query' tree = z 'div''test'$ = querytree$'div'contentsshouldbe 'test' tree = z 'div' z '.class' z '#id' z 'span' 'abc' z 'span' 'xyz' $ = querytree$$ = queryalltree $'div .class #id span'contentsshouldbe 'abc'$'span'contentsshouldbe 'abc' $$'div .class #id span'lengthshouldbe 2$$'span'lengthshouldbe 2 # Properties tree = z 'input'type: 'button'$ = query tree$'input'typeshouldbe 'button' # Attributes tree = z 'div' z 'a'href: 'abc''aaa' $ = query tree$'a[href=abc]'contentsshouldbe 'aaa'
query(vtree, selector)
Returns first matching vNode, with a contents
property
This method supports currying
tree = z 'div''test'$ = querytree$'div'contentsshouldbe 'test'
query.all()
Returns all matching vNodes, with contents
properties
This method supports currying
tree = z 'div''test'$$ = queryalltree$$'div'0contentsshouldbe 'test'