closest-ng

1.1.0 • Public • Published

Closest-ng

GitHub license npm version CircleCI Status Greenkeeper badge

Finds the closest ancestor of an element (or the current element itself) that matches a selector. Uses the native closest method if available in the browser.

Installation

$ yarn add closest-ng

API

closest(element, selector)

  • element - will check this element's parents
  • selector - CSS selector to match parents

Example:

var closest = require('closest-ng');
 
closest(document.body, 'html') === document.documentElement
closest(document.body, 'body') === document.body

Types

Both TypeScript and Flow type definitions for this module are included! The type definitions won't require any configuration to use.

Package Sidebar

Install

npm i closest-ng

Weekly Downloads

60

Version

1.1.0

License

MIT

Unpacked Size

9.28 kB

Total Files

13

Last publish

Collaborators

  • macil