# descended-from

> Check if a DOM node is descended from another node or selector.

Latest version **1.0.2** (published 2017-03-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install descended-from
pnpm add descended-from
yarn add descended-from
bun add descended-from
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-03-20 |
| First published | 2017-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Daniel Bergmann |
| Maintainers | bergmann |
| Keywords | dom, html |

## Links

- npm: https://www.npmjs.com/package/descended-from
- Repository: https://github.com/brgmnn/descended-from
- Homepage: https://github.com/brgmnn/descended-from#readme
- Issues: https://github.com/brgmnn/descended-from/issues
- npm.io page: https://npm.io/package/descended-from

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2017-03-20
- 1.0.1 — 2017-02-10
- 1.0.0 — 2017-02-09
- 0.0.3 — 2017-02-08
- 0.0.2 — 2017-02-08
- 0.0.1 — 2017-02-08

## README

# Descended From

[![npm](https://img.shields.io/npm/v/descended-from.svg)](https://www.npmjs.com/package/descended-from)
[![Build Status](https://travis-ci.org/brgmnn/descended-from.svg?branch=master)](https://travis-ci.org/brgmnn/descended-from)
[![Coverage Status](https://coveralls.io/repos/github/brgmnn/descended-from/badge.svg?branch=master)](https://coveralls.io/github/brgmnn/descended-from?branch=master)
[![npm](https://img.shields.io/npm/dm/descended-from.svg)](https://www.npmjs.com/package/descended-from)
[![GitHub license](https://img.shields.io/npm/l/descended-from.svg)](https://raw.githubusercontent.com/brgmnn/descended-from/master/LICENSE)

Check if a DOM node is descended from another node or selector.

## Installation

```
npm install descended-from
```

## Usage

```
var descendedFrom = require('descended-from');

var child = document.getElementById('child');
var parent = document.getElementById('parent');

descendedFrom(child, parent) // -> true
```

given this DOM

```
<div id="parent">
  <div>
    <div id="child"></div>
  </div>
</div>
```

This is equivalent running `parent.contains(child)`. However you can do more with `descended-from`.

### Check if descended from an element with a class

```
var child = document.getElementById('child');

descendedFrom(child, '.parent') // -> true
```

given this DOM

```
<div class="parent">
  <div>
    <div id="child"></div>
  </div>
</div>
```

### Check if descended from an element with an ID

```
var child = document.getElementById('child');

descendedFrom(child, '#parent') // -> true
```

given this DOM

```
<div id="parent">
  <div>
    <div id="child"></div>
  </div>
</div>
```

## Browser support

Chrome 1+, Firefox 3.5+, IE 9+, Opera 10.5+, Safari 5+

Browser functions depended on so far are:
- `element.classList()`
- `element.contains()`
- `string.trim()`
- `string.charAt()`
- `string.replace()` (accepting string parameters)

## License

MIT

---
_Source: https://npm.io/package/descended-from · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
