Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fisker/get-text-nodes

get child text nodes
https://github.com/fisker/get-text-nodes

Last synced: 6 days ago
JSON representation

get child text nodes

Awesome Lists containing this project

README

        

# get-text-nodes

> get child text nodes

## Install

```sh
yarn add get-text-nodes
```

## Files

```text
dist/
├─ index.js ( UMD )
├─ index.min.js ( UMD, compressed )
├─ index.mjs ( ES Module )
└─ index.min.mjs ( ES Module, compressed )
```

## Usage

```html

import getTextNodes from 'https://unpkg.com/get-text-nodes?module'

```

`UMD` build exports a global function `getTextNodes`

## API

### getTextNodes(nodeList, options?)

get child text nodes from `nodeList`

```js
getTextNodes(document.body)
// -> [text, text, ...]
```

#### nodeList

- `NodeList`, `Node`, `Array` or any `arrayLike`

```js
// Node
getTextNodes(document.body)

// HTMLCollection
getTextNodes(document.getElementsByTagName('*'))

// NodeList
getTextNodes(document.querySelectorAll('*'))

// Array
getTextNodes([...document.getElementsByTagName('*')])
```

#### options.ignoreWhiteSpace

- Type: `boolean`
- Default: `true`
- ignore WhiteSpace text node

#### options.deep

- Type: `boolean`
- Default: `true`
- get text nodes from children