dom5
- Version 3.0.1
- Published
- 85.6 kB
- 3 dependencies
- BSD-3-Clause license
Install
npm i dom5yarn add dom5pnpm add dom5Overview
Utilities for working with parse5 ASTs
Index
Variables
Functions
- append()
- childNodesIncludeTemplate()
- cloneNode()
- defaultChildNodes()
- getAttribute()
- getAttributeIndex()
- getTextContent()
- hasAttribute()
- hasSpaceSeparatedAttrValue()
- insertAfter()
- insertBefore()
- isCommentNode()
- isDocument()
- isDocumentFragment()
- isElement()
- isTextNode()
- nodeWalk()
- nodeWalkAll()
- nodeWalkAllPrior()
- nodeWalkAncestors()
- nodeWalkPrior()
- normalize()
- query()
- queryAll()
- remove()
- removeAttribute()
- removeFakeRootElements()
- removeNodeSaveChildren()
- replace()
- setAttribute()
- setTextContent()
- treeMap()
Type Aliases
Variables
variable constructors
const constructors: {    text: (value: string) => Node;    comment: (comment: string) => Node;    element: (tagName: string, namespace?: string | undefined) => Node;    fragment: () => Node;};variable predicates
const predicates: {    hasClass: (name: string) => Predicate;    hasAttr: (attr: string) => Predicate;    hasAttrValue: (attr: string, value: string) => Predicate;    hasMatchingTagName: (regex: RegExp) => Predicate;    hasSpaceSeparatedAttrValue: typeof hasSpaceSeparatedAttrValue;    hasTagName: (name: string) => Predicate;    hasTextValue: (value: string) => Predicate;    AND: (...predicates: Predicate[]) => Predicate;    OR: (...predicates: Predicate[]) => Predicate;    NOT: (predicateFn: Predicate) => Predicate;    parentMatches: (predicateFn: Predicate) => Predicate;};Functions
function append
append: (parent: Node, newNode: Node) => void;function childNodesIncludeTemplate
childNodesIncludeTemplate: (node: Node) => Node[] | undefined;function cloneNode
cloneNode: (node: Node) => Node;function defaultChildNodes
defaultChildNodes: (node: Node) => Node[] | undefined;function getAttribute
getAttribute: (element: Node, name: string) => string | null;- Returns- The string value of attribute - name, or- null.
function getAttributeIndex
getAttributeIndex: (element: Node, name: string) => number;function getTextContent
getTextContent: (node: Node) => string;- Return the text value of a node or element - Equivalent to - node.textContentin the browser
function hasAttribute
hasAttribute: (element: Node, name: string) => boolean;- Returns- trueiff [element] has the attribute [name],- falseotherwise.
function hasSpaceSeparatedAttrValue
hasSpaceSeparatedAttrValue: (name: string, value: string) => Predicate;function insertAfter
insertAfter: (parent: Node, target: Node, newNode: Node) => void;function insertBefore
insertBefore: (parent: Node, target: Node, newNode: Node) => void;function isCommentNode
isCommentNode: (node: Node) => boolean;function isDocument
isDocument: (node: Node) => boolean;function isDocumentFragment
isDocumentFragment: (node: Node) => boolean;function isElement
isElement: (node: Node) => boolean;function isTextNode
isTextNode: (node: Node) => boolean;function nodeWalk
nodeWalk: (    node: Node,    predicate: Predicate,    getChildNodes?: GetChildNodes) => Node | null;- Walk the tree down from - node, applying the- predicatefunction. Return the first node that matches the given predicate.- Returns- nullif no node matches, parse5 node object if a node matches.
function nodeWalkAll
nodeWalkAll: (    node: Node,    predicate: Predicate,    matches?: Node[],    getChildNodes?: GetChildNodes) => Node[];- Walk the tree down from - node, applying the- predicatefunction. All nodes matching the predicate function from- nodeto leaves will be returned.
function nodeWalkAllPrior
nodeWalkAllPrior: (node: Node, predicate: Predicate, matches?: Node[]) => Node[];- Equivalent to - nodeWalkAll, but only returns nodes that are either ancestors or earlier cousins/siblings in the document.- Nodes are returned in reverse document order, starting from - node.
function nodeWalkAncestors
nodeWalkAncestors: (node: Node, predicate: Predicate) => Node | undefined;- Walk the tree up from the parent of - node, to its grandparent and so on to the root of the tree. Return the first ancestor that matches the given predicate.
function nodeWalkPrior
nodeWalkPrior: (node: Node, predicate: Predicate) => Node | undefined;- Equivalent to - nodeWalk, but only returns nodes that are either ancestors or earlier siblings in the document.- Nodes are searched in reverse document order, starting from the sibling prior to - node.
function normalize
normalize: (node: Node) => void;- Normalize the text inside an element - Equivalent to - element.normalize()in the browser See https://developer.mozilla.org/en-US/docs/Web/API/Node/normalize
function query
query: (    node: Node,    predicate: Predicate,    getChildNodes?: GetChildNodes) => Node | null;- Equivalent to - nodeWalk, but only matches elements
function queryAll
queryAll: (    node: Node,    predicate: Predicate,    matches?: Node[],    getChildNodes?: GetChildNodes) => Node[];- Equivalent to - nodeWalkAll, but only matches elements
function remove
remove: (node: Node) => void;function removeAttribute
removeAttribute: (element: Node, name: string) => void;function removeFakeRootElements
removeFakeRootElements: (ast: Node) => void;- When parse5 parses an HTML document with - parse, it injects missing root elements (html, head and body) if they are missing. This function removes these from the AST if they have no location info, so it requires that the- parse5.parsebe used with the- locationInfooption of- true.
function removeNodeSaveChildren
removeNodeSaveChildren: (node: Node) => void;- Removes a node and places its children in its place. If the node has no parent, the operation is impossible and no action takes place. 
function replace
replace: (oldNode: Node, newNode: Node) => void;function setAttribute
setAttribute: (element: Node, name: string, value: string) => void;function setTextContent
setTextContent: (node: Node, value: string) => void;- Set the text value of a node or element - Equivalent to - node.textContent = valuein the browser
function treeMap
treeMap: <U>(node: Node, mapfn: (node: Node) => U[]) => U[];- Applies - mapfnto- nodeand the tree below- node, returning a flattened list of results.
Type Aliases
type GetChildNodes
type GetChildNodes = (node: Node) => Node[] | undefined;type Predicate
type Predicate = (node: Node) => boolean;Package Files (5)
Dependencies (3)
Dev Dependencies (8)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/dom5.
- Markdown[](https://www.jsdocs.io/package/dom5)
- HTML<a href="https://www.jsdocs.io/package/dom5"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
 Package analyzed in 1869 ms.
- Missing or incorrect documentation? Open an issue for this package.
