JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 22
  • Score
    100M100P100Q63966F
  • License Public Domain

Select virtual-dom nodes using css selectors

Package Exports

  • vtree-select

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vtree-select) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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