vtree-select
Select virtual-dom nodes using css selectors
Last updated 4 years ago by parshap .
Public Domain · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install vtree-select 
SYNC missed versions from official npm registry.

vtree-select

build status

Select vtree nodes (used by virtual-dom) using css selectors.

Selector matching is done using cssauron. See the documentation for details on supported selectors.

Usage

var select = require("vtree-select");
var h = require("virtual-hyperscript");

var vtree = h("div", [
  h("span", "hello"),
  h("strong", "world"),
]);

select("div strong")(vtree)
// -> <strong>world</strong> (VNode object)

select("div strong").matches(vtree)
// -> false

select("div").matches(vtree)
// -> true

API

require("vtree-select")(selector [, options]) -> match

Create a match function that takes a vtree and returns an array of nodes that match the selector.

options.caseSensitiveTag enables case sensitivity for tag names. This is useful for XML, which has case-sensitive tag names. HTML tag names are not case sensitive.

match(vtree) -> array

Returns an array of matched nodes, or null if no nodes match.

Unlike css and querySelectorAll, text nodes are matched and returned.

Selectors are case-sensitive.

match.matches(vtree) -> boolean

Returns true if the vtree matches the selector, or false otherwise.

Installation

npm install vtree-select

Current Tags

  • 2.1.0                                ...           latest (4 years ago)

8 Versions

  • 2.1.0                                ...           4 years ago
  • 2.0.0                                ...           5 years ago
  • 1.1.1                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.3                                ...           6 years ago
  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 1
This Week 2
This Month 2
Last Day 0
Last Week 0
Last Month 3
Dependencies (1)
Dev Dependencies (1)

Copyright 2014 - 2016 © taobao.org |