JSPM

  • Created
  • Published
  • Downloads 273
  • Score
    100M100P100Q90306F
  • License MIT

Utilities for DOM

Package Exports

  • extra-dom

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 (extra-dom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

extra-dom

Utilities for DOM.

Install

npm install --save extra-dom
# or
yarn add extra-dom

API

flatMap

function flatMap(node: Node, fn: (node: Node) => Node[]): Node[]

Traverse the node tree and do flatMap.

  • []: remove current node
  • [node]: replace current node
  • [node1, node2, ...nodeN]: replace current node with more nodes

map

function map(node: Node, fn: (node: Node) => Node): Node

Traverse the node tree and do map.

filter

function filter(node: Node, predicate: (node: Node) => boolean): Node | null

Traverse the node tree and do filter.

unwrap

function unwrap(node: Node, predicate: (node: Node) => boolean): Node[]

Traverse the node tree and do unwrap.

parse

function parse(html: string): Node[]

stringify

function stringify(nodes: Node[]): string

normalize

function normalize(html: string): string

It is the shortcut for stringify(parse(html)).

removeAllChildren

function removeAllChildren(node: Node): void

removeAttributes

function removeAttributes(node: Node, predicate: (name: string) => boolean): void