New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

parse5-utilities

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse5-utilities

Low-level parse5 node manipulation utilities. ESM-compatible version of parse5-utils.

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
1.8K
-14.05%
Maintainers
1
Weekly downloads
 
Created
Source

NPM version Downloads CI

parse5-utilities

Low-level parse5 node manipulation utilities.

API

parse

Parse an HTML string. If smart is true, returns a document or documentFragment based on the input. Otherwise, always parses it as a document.

parse(html: string, smart?: boolean): Document | DocumentFragment

createFragment

Parses HTML as a fragment.

createFragment(html: string): DocumentFragment

stringify

Converts an AST node into an HTML string.

stringify(node: Node): string

attributesOf

Get the attributes of a node as an object.

attributesOf(node: Node): Record<string, string>

setAttribute

Set an attribute on a node.

setAttribute(node: Node, key: string, value: string): Node

getAttribute

Get an attribute value from a node.

getAttribute(node: Node, key: string): string | undefined

removeAttribute

Remove an attribute from a node.

removeAttribute(node: Node, key: string): void

toAttrs

Convert an object of attributes into an array of attribute objects.

toAttrs(attributes: Record<string, string>): Attribute[]

createNode

Create a new element node with the specified tag name.

createNode(tagName: string): Element

createTextNode

Create a new text node with the specified text content.

createTextNode(text: string): TextNode

prepend

Add a child to a node, making it the first child.

prepend(parent: ParentNode, node: ChildNode): ChildNode

append

Add a child to a node, making it the last child.

append(parent: ParentNode, node: ChildNode): ChildNode

replace

Replace a node with another node.

replace(originalNode: ChildNode, newNode: ChildNode): ChildNode | undefined

remove

Remove a node from its parent.

remove(node: ChildNode): ChildNode

flatten

Get all the nodes in a tree as a flat array.

flatten(node: Node | Node[]): Node[]

textOf

Get the text content of a node. Throws an error if the node has multiple children or non-text children.

textOf(node: ParentNode): string

setText

Set the text content of a node.

setText(node: ParentNode, text: string): ParentNode

isDocument

Check if a string is likely a complete HTML document.

isDocument(string: string): boolean

License

MIT License

Copyright (c) 2014 Jonathan Ong me@jongleberry.com
Copyright (c) 2025 Cezar Augusto boss@cezaraugusto.net

Keywords

html

FAQs

Package last updated on 03 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts