Socket
Socket
Sign inDemoInstall

domutils

Package Overview
Dependencies
4
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.8.0 to 3.0.0

lib/esm/feeds.d.ts

30

lib/feeds.d.ts

@@ -1,4 +0,19 @@

import type { Node } from "domhandler";
import type { AnyNode } from "domhandler";
/**
* The type of a media item.
*
* @category Feeds
*/
export declare type FeedItemMediaMedium = "image" | "audio" | "video" | "document" | "executable";
/**
* The type of a media item.
*
* @category Feeds
*/
export declare type FeedItemMediaExpression = "sample" | "full" | "nonstop";
/**
* A media item of a feed entry.
*
* @category Feeds
*/
export interface FeedItemMedia {

@@ -20,2 +35,7 @@ medium: FeedItemMediaMedium | undefined;

}
/**
* An entry of a feed.
*
* @category Feeds
*/
export interface FeedItem {

@@ -29,2 +49,7 @@ id?: string;

}
/**
* The root of a feed.
*
* @category Feeds
*/
export interface Feed {

@@ -43,6 +68,7 @@ type: string;

*
* @category Feeds
* @param doc - The DOM to to extract the feed from.
* @returns The feed.
*/
export declare function getFeed(doc: Node[]): Feed | null;
export declare function getFeed(doc: AnyNode[]): Feed | null;
//# sourceMappingURL=feeds.d.ts.map

31

lib/feeds.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFeed = void 0;
var stringify_1 = require("./stringify");
var legacy_1 = require("./legacy");
var stringify_js_1 = require("./stringify.js");
var legacy_js_1 = require("./legacy.js");
/**
* Get the feed object from the root of a DOM tree.
*
* @category Feeds
* @param doc - The DOM to to extract the feed from.

@@ -32,3 +33,3 @@ * @returns The feed.

type: "atom",
items: (0, legacy_1.getElementsByTagName)("entry", childs).map(function (item) {
items: (0, legacy_js_1.getElementsByTagName)("entry", childs).map(function (item) {
var _a;

@@ -39,3 +40,3 @@ var children = item.children;

addConditionally(entry, "title", "title", children);
var href = (_a = getOneElement("link", children)) === null || _a === void 0 ? void 0 : _a.attribs.href;
var href = (_a = getOneElement("link", children)) === null || _a === void 0 ? void 0 : _a.attribs["href"];
if (href) {

@@ -57,3 +58,3 @@ entry.link = href;

addConditionally(feed, "title", "title", childs);
var href = (_a = getOneElement("link", childs)) === null || _a === void 0 ? void 0 : _a.attribs.href;
var href = (_a = getOneElement("link", childs)) === null || _a === void 0 ? void 0 : _a.attribs["href"];
if (href) {

@@ -82,3 +83,3 @@ feed.link = href;

id: "",
items: (0, legacy_1.getElementsByTagName)("item", feedRoot.children).map(function (item) {
items: (0, legacy_js_1.getElementsByTagName)("item", feedRoot.children).map(function (item) {
var children = item.children;

@@ -124,7 +125,7 @@ var entry = { media: getMediaElements(children) };

function getMediaElements(where) {
return (0, legacy_1.getElementsByTagName)("media:content", where).map(function (elem) {
return (0, legacy_js_1.getElementsByTagName)("media:content", where).map(function (elem) {
var attribs = elem.attribs;
var media = {
medium: attribs.medium,
isDefault: !!attribs.isDefault,
medium: attribs["medium"],
isDefault: !!attribs["isDefault"],
};

@@ -143,5 +144,4 @@ for (var _i = 0, MEDIA_KEYS_STRING_1 = MEDIA_KEYS_STRING; _i < MEDIA_KEYS_STRING_1.length; _i++) {

}
if (attribs.expression) {
media.expression =
attribs.expression;
if (attribs["expression"]) {
media.expression = attribs["expression"];
}

@@ -159,3 +159,3 @@ return media;

function getOneElement(tagName, node) {
return (0, legacy_1.getElementsByTagName)(tagName, node, true, 1)[0];
return (0, legacy_js_1.getElementsByTagName)(tagName, node, true, 1)[0];
}

@@ -166,3 +166,3 @@ /**

* @param tagName Tag name to look for.
* @param where Node to search in.
* @param where Node to search in.
* @param recurse Whether to recurse into child nodes.

@@ -173,3 +173,3 @@ * @returns The text content of the element.

if (recurse === void 0) { recurse = false; }
return (0, stringify_1.textContent)((0, legacy_1.getElementsByTagName)(tagName, where, recurse, 1)).trim();
return (0, stringify_js_1.textContent)((0, legacy_js_1.getElementsByTagName)(tagName, where, recurse, 1)).trim();
}

@@ -200,1 +200,2 @@ /**

}
//# sourceMappingURL=feeds.js.map

@@ -1,9 +0,14 @@

import { Node } from "domhandler";
import { AnyNode } from "domhandler";
/**
* Given an array of nodes, remove any member that is contained by another.
*
* @category Helpers
* @param nodes Nodes to filter.
* @returns Remaining nodes that aren't subtrees of each other.
*/
export declare function removeSubsets(nodes: Node[]): Node[];
export declare function removeSubsets(nodes: AnyNode[]): AnyNode[];
/**
* @category Helpers
* @see {@link http://dom.spec.whatwg.org/#dom-node-comparedocumentposition}
*/
export declare const enum DocumentPosition {

@@ -18,3 +23,3 @@ DISCONNECTED = 1,

* Compare the position of one node against another node in any other document.
* The return value is a bitmask with the following values:
* The return value is a bitmask with the values from {@link DocumentPosition}.
*

@@ -30,3 +35,3 @@ * Document order:

* > nodes of an element occur after the element and before its children. The
* > relative order of attribute nodes is implementation-dependent./
* > relative order of attribute nodes is implementation-dependent.
*

@@ -36,2 +41,3 @@ * Source:

*
* @category Helpers
* @param nodeA The first node to use in the comparison

@@ -44,12 +50,13 @@ * @param nodeB The second node to use in the comparison

*/
export declare function compareDocumentPosition(nodeA: Node, nodeB: Node): number;
export declare function compareDocumentPosition(nodeA: AnyNode, nodeB: AnyNode): number;
/**
* Sort an array of nodes based on their relative position in the document and
* remove any duplicate nodes. If the array contains nodes that do not belong
* to the same document, sort order is unspecified.
* remove any duplicate nodes. If the array contains nodes that do not belong to
* the same document, sort order is unspecified.
*
* @category Helpers
* @param nodes Array of DOM nodes.
* @returns Collection of unique nodes, sorted in document order.
*/
export declare function uniqueSort<T extends Node>(nodes: T[]): T[];
export declare function uniqueSort<T extends AnyNode>(nodes: T[]): T[];
//# sourceMappingURL=helpers.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniqueSort = exports.compareDocumentPosition = exports.removeSubsets = void 0;
exports.uniqueSort = exports.compareDocumentPosition = exports.DocumentPosition = exports.removeSubsets = void 0;
var domhandler_1 = require("domhandler");

@@ -8,2 +8,3 @@ /**

*
* @category Helpers
* @param nodes Nodes to filter.

@@ -40,4 +41,16 @@ * @returns Remaining nodes that aren't subtrees of each other.

/**
* @category Helpers
* @see {@link http://dom.spec.whatwg.org/#dom-node-comparedocumentposition}
*/
var DocumentPosition;
(function (DocumentPosition) {
DocumentPosition[DocumentPosition["DISCONNECTED"] = 1] = "DISCONNECTED";
DocumentPosition[DocumentPosition["PRECEDING"] = 2] = "PRECEDING";
DocumentPosition[DocumentPosition["FOLLOWING"] = 4] = "FOLLOWING";
DocumentPosition[DocumentPosition["CONTAINS"] = 8] = "CONTAINS";
DocumentPosition[DocumentPosition["CONTAINED_BY"] = 16] = "CONTAINED_BY";
})(DocumentPosition = exports.DocumentPosition || (exports.DocumentPosition = {}));
/**
* Compare the position of one node against another node in any other document.
* The return value is a bitmask with the following values:
* The return value is a bitmask with the values from {@link DocumentPosition}.
*

@@ -53,3 +66,3 @@ * Document order:

* > nodes of an element occur after the element and before its children. The
* > relative order of attribute nodes is implementation-dependent./
* > relative order of attribute nodes is implementation-dependent.
*

@@ -59,2 +72,3 @@ * Source:

*
* @category Helpers
* @param nodeA The first node to use in the comparison

@@ -89,3 +103,3 @@ * @param nodeB The second node to use in the comparison

if (idx === 0) {
return 1 /* DISCONNECTED */;
return DocumentPosition.DISCONNECTED;
}

@@ -98,10 +112,10 @@ var sharedParent = aParents[idx - 1];

if (sharedParent === nodeB) {
return 4 /* FOLLOWING */ | 16 /* CONTAINED_BY */;
return DocumentPosition.FOLLOWING | DocumentPosition.CONTAINED_BY;
}
return 4 /* FOLLOWING */;
return DocumentPosition.FOLLOWING;
}
if (sharedParent === nodeA) {
return 2 /* PRECEDING */ | 8 /* CONTAINS */;
return DocumentPosition.PRECEDING | DocumentPosition.CONTAINS;
}
return 2 /* PRECEDING */;
return DocumentPosition.PRECEDING;
}

@@ -111,5 +125,6 @@ exports.compareDocumentPosition = compareDocumentPosition;

* Sort an array of nodes based on their relative position in the document and
* remove any duplicate nodes. If the array contains nodes that do not belong
* to the same document, sort order is unspecified.
* remove any duplicate nodes. If the array contains nodes that do not belong to
* the same document, sort order is unspecified.
*
* @category Helpers
* @param nodes Array of DOM nodes.

@@ -122,6 +137,6 @@ * @returns Collection of unique nodes, sorted in document order.

var relative = compareDocumentPosition(a, b);
if (relative & 2 /* PRECEDING */) {
if (relative & DocumentPosition.PRECEDING) {
return -1;
}
else if (relative & 4 /* FOLLOWING */) {
else if (relative & DocumentPosition.FOLLOWING) {
return 1;

@@ -134,1 +149,2 @@ }

exports.uniqueSort = uniqueSort;
//# sourceMappingURL=helpers.js.map

@@ -1,10 +0,10 @@

export * from "./stringify";
export * from "./traversal";
export * from "./manipulation";
export * from "./querying";
export * from "./legacy";
export * from "./helpers";
export * from "./feeds";
export * from "./stringify.js";
export * from "./traversal.js";
export * from "./manipulation.js";
export * from "./querying.js";
export * from "./legacy.js";
export * from "./helpers.js";
export * from "./feeds.js";
/** @deprecated Use these methods from `domhandler` directly. */
export { isTag, isCDATA, isText, isComment, isDocument, hasChildren, } from "domhandler";
//# sourceMappingURL=index.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -14,9 +18,9 @@ if (k2 === undefined) k2 = k;

exports.hasChildren = exports.isDocument = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = void 0;
__exportStar(require("./stringify"), exports);
__exportStar(require("./traversal"), exports);
__exportStar(require("./manipulation"), exports);
__exportStar(require("./querying"), exports);
__exportStar(require("./legacy"), exports);
__exportStar(require("./helpers"), exports);
__exportStar(require("./feeds"), exports);
__exportStar(require("./stringify.js"), exports);
__exportStar(require("./traversal.js"), exports);
__exportStar(require("./manipulation.js"), exports);
__exportStar(require("./querying.js"), exports);
__exportStar(require("./legacy.js"), exports);
__exportStar(require("./helpers.js"), exports);
__exportStar(require("./feeds.js"), exports);
/** @deprecated Use these methods from `domhandler` directly. */

@@ -30,1 +34,2 @@ var domhandler_1 = require("domhandler");

Object.defineProperty(exports, "hasChildren", { enumerable: true, get: function () { return domhandler_1.hasChildren; } });
//# sourceMappingURL=index.js.map

@@ -1,4 +0,11 @@

import { Node, Element } from "domhandler";
import { ElementType } from "domelementtype";
interface TestElementOpts {
import { AnyNode, Element } from "domhandler";
import type { ElementType } from "domelementtype";
/**
* An object with keys to check elements against. If a key is `tag_name`,
* `tag_type` or `tag_contains`, it will check the value against that specific
* value. Otherwise, it will check an attribute with the key's name.
*
* @category Legacy Query Functions
*/
export interface TestElementOpts {
tag_name?: string | ((name: string) => boolean);

@@ -10,2 +17,3 @@ tag_type?: string | ((name: string) => boolean);

/**
* @category Legacy Query Functions
* @param options An object describing nodes to look for.

@@ -15,4 +23,5 @@ * @param node The element to test.

*/
export declare function testElement(options: TestElementOpts, node: Node): boolean;
export declare function testElement(options: TestElementOpts, node: AnyNode): boolean;
/**
* @category Legacy Query Functions
* @param options An object describing nodes to look for.

@@ -24,4 +33,5 @@ * @param nodes Nodes to search through.

*/
export declare function getElements(options: TestElementOpts, nodes: Node | Node[], recurse: boolean, limit?: number): Node[];
export declare function getElements(options: TestElementOpts, nodes: AnyNode | AnyNode[], recurse: boolean, limit?: number): AnyNode[];
/**
* @category Legacy Query Functions
* @param id The unique ID attribute value to look for.

@@ -32,4 +42,5 @@ * @param nodes Nodes to search through.

*/
export declare function getElementById(id: string | ((id: string) => boolean), nodes: Node | Node[], recurse?: boolean): Element | null;
export declare function getElementById(id: string | ((id: string) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean): Element | null;
/**
* @category Legacy Query Functions
* @param tagName Tag name to search for.

@@ -41,4 +52,5 @@ * @param nodes Nodes to search through.

*/
export declare function getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: Node | Node[], recurse?: boolean, limit?: number): Element[];
export declare function getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean, limit?: number): Element[];
/**
* @category Legacy Query Functions
* @param type Element type to look for.

@@ -50,4 +62,3 @@ * @param nodes Nodes to search through.

*/
export declare function getElementsByTagType(type: ElementType | ((type: ElementType) => boolean), nodes: Node | Node[], recurse?: boolean, limit?: number): Node[];
export {};
export declare function getElementsByTagType(type: ElementType | ((type: ElementType) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[];
//# sourceMappingURL=legacy.d.ts.map

@@ -5,3 +5,3 @@ "use strict";

var domhandler_1 = require("domhandler");
var querying_1 = require("./querying");
var querying_js_1 = require("./querying.js");
var Checks = {

@@ -33,3 +33,4 @@ tag_name: function (name) {

* @param value Attribute value to look for.
* @returns A function to check whether the a node has an attribute with a particular value.
* @returns A function to check whether the a node has an attribute with a
* particular value.
*/

@@ -45,4 +46,4 @@ function getAttribCheck(attrib, value) {

* @param b Second function to combine.
* @returns A function taking a node and returning `true` if either
* of the input functions returns `true` for the node.
* @returns A function taking a node and returning `true` if either of the input
* functions returns `true` for the node.
*/

@@ -54,4 +55,4 @@ function combineFuncs(a, b) {

* @param options An object describing nodes to look for.
* @returns A function executing all checks in `options` and returning `true`
* if any of them match a node.
* @returns A function executing all checks in `options` and returning `true` if
* any of them match a node.
*/

@@ -68,2 +69,3 @@ function compileTest(options) {

/**
* @category Legacy Query Functions
* @param options An object describing nodes to look for.

@@ -79,2 +81,3 @@ * @param node The element to test.

/**
* @category Legacy Query Functions
* @param options An object describing nodes to look for.

@@ -89,6 +92,7 @@ * @param nodes Nodes to search through.

var test = compileTest(options);
return test ? (0, querying_1.filter)(test, nodes, recurse, limit) : [];
return test ? (0, querying_js_1.filter)(test, nodes, recurse, limit) : [];
}
exports.getElements = getElements;
/**
* @category Legacy Query Functions
* @param id The unique ID attribute value to look for.

@@ -103,6 +107,7 @@ * @param nodes Nodes to search through.

nodes = [nodes];
return (0, querying_1.findOne)(getAttribCheck("id", id), nodes, recurse);
return (0, querying_js_1.findOne)(getAttribCheck("id", id), nodes, recurse);
}
exports.getElementById = getElementById;
/**
* @category Legacy Query Functions
* @param tagName Tag name to search for.

@@ -117,6 +122,7 @@ * @param nodes Nodes to search through.

if (limit === void 0) { limit = Infinity; }
return (0, querying_1.filter)(Checks.tag_name(tagName), nodes, recurse, limit);
return (0, querying_js_1.filter)(Checks["tag_name"](tagName), nodes, recurse, limit);
}
exports.getElementsByTagName = getElementsByTagName;
/**
* @category Legacy Query Functions
* @param type Element type to look for.

@@ -131,4 +137,5 @@ * @param nodes Nodes to search through.

if (limit === void 0) { limit = Infinity; }
return (0, querying_1.filter)(Checks.tag_type(type), nodes, recurse, limit);
return (0, querying_js_1.filter)(Checks["tag_type"](type), nodes, recurse, limit);
}
exports.getElementsByTagType = getElementsByTagType;
//# sourceMappingURL=legacy.js.map

@@ -1,43 +0,49 @@

import type { Node, Element } from "domhandler";
import type { ChildNode, Element } from "domhandler";
/**
* Remove an element from the dom
*
* @category Manipulation
* @param elem The element to be removed
*/
export declare function removeElement(elem: Node): void;
export declare function removeElement(elem: ChildNode): void;
/**
* Replace an element in the dom
*
* @category Manipulation
* @param elem The element to be replaced
* @param replacement The element to be added
*/
export declare function replaceElement(elem: Node, replacement: Node): void;
export declare function replaceElement(elem: ChildNode, replacement: ChildNode): void;
/**
* Append a child to an element.
*
* @category Manipulation
* @param elem The element to append to.
* @param child The element to be added as a child.
*/
export declare function appendChild(elem: Element, child: Node): void;
export declare function appendChild(elem: Element, child: ChildNode): void;
/**
* Append an element after another.
*
* @category Manipulation
* @param elem The element to append after.
* @param next The element be added.
*/
export declare function append(elem: Node, next: Node): void;
export declare function append(elem: ChildNode, next: ChildNode): void;
/**
* Prepend a child to an element.
*
* @category Manipulation
* @param elem The element to prepend before.
* @param child The element to be added as a child.
*/
export declare function prependChild(elem: Element, child: Node): void;
export declare function prependChild(elem: Element, child: ChildNode): void;
/**
* Prepend an element before another.
*
* @category Manipulation
* @param elem The element to prepend before.
* @param prev The element be added.
*/
export declare function prepend(elem: Node, prev: Node): void;
export declare function prepend(elem: ChildNode, prev: ChildNode): void;
//# sourceMappingURL=manipulation.d.ts.map

@@ -7,2 +7,3 @@ "use strict";

*
* @category Manipulation
* @param elem The element to be removed

@@ -24,2 +25,3 @@ */

*
* @category Manipulation
* @param elem The element to be replaced

@@ -47,2 +49,3 @@ * @param replacement The element to be added

*
* @category Manipulation
* @param elem The element to append to.

@@ -68,2 +71,3 @@ * @param child The element to be added as a child.

*
* @category Manipulation
* @param elem The element to append after.

@@ -95,2 +99,3 @@ * @param next The element be added.

*
* @category Manipulation
* @param elem The element to prepend before.

@@ -116,2 +121,3 @@ * @param child The element to be added as a child.

*
* @category Manipulation
* @param elem The element to prepend before.

@@ -136,1 +142,2 @@ * @param prev The element be added.

exports.prepend = prepend;
//# sourceMappingURL=manipulation.js.map

@@ -1,5 +0,6 @@

import { Node, Element } from "domhandler";
import { Element, AnyNode } from "domhandler";
/**
* Search a node and its children for nodes passing a test function.
*
* @category Querying
* @param test Function to test nodes on.

@@ -11,6 +12,7 @@ * @param node Node to search. Will be included in the result set if it matches.

*/
export declare function filter(test: (elem: Node) => boolean, node: Node | Node[], recurse?: boolean, limit?: number): Node[];
export declare function filter(test: (elem: AnyNode) => boolean, node: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[];
/**
* Search an array of node and its children for nodes passing a test function.
*
* @category Querying
* @param test Function to test nodes on.

@@ -22,14 +24,17 @@ * @param nodes Array of nodes to search.

*/
export declare function find(test: (elem: Node) => boolean, nodes: Node[], recurse: boolean, limit: number): Node[];
export declare function find(test: (elem: AnyNode) => boolean, nodes: AnyNode[], recurse: boolean, limit: number): AnyNode[];
/**
* Finds the first element inside of an array that matches a test function.
*
* @category Querying
* @param test Function to test nodes on.
* @param nodes Array of nodes to search.
* @returns The first node in the array that passes `test`.
* @deprecated Use `Array.prototype.find` directly.
*/
export declare function findOneChild(test: (elem: Node) => boolean, nodes: Node[]): Node | undefined;
export declare function findOneChild<T>(test: (elem: T) => boolean, nodes: T[]): T | undefined;
/**
* Finds one element in a tree that passes a test.
*
* @category Querying
* @param test Function to test nodes on.

@@ -40,9 +45,10 @@ * @param nodes Array of nodes to search.

*/
export declare function findOne(test: (elem: Element) => boolean, nodes: Node[], recurse?: boolean): Element | null;
export declare function findOne(test: (elem: Element) => boolean, nodes: AnyNode[], recurse?: boolean): Element | null;
/**
* @category Querying
* @param test Function to test nodes on.
* @param nodes Array of nodes to search.
* @returns Whether a tree of nodes contains at least one node passing a test.
* @returns Whether a tree of nodes contains at least one node passing the test.
*/
export declare function existsOne(test: (elem: Element) => boolean, nodes: Node[]): boolean;
export declare function existsOne(test: (elem: Element) => boolean, nodes: AnyNode[]): boolean;
/**

@@ -53,2 +59,3 @@ * Search and array of nodes and its children for nodes passing a test function.

*
* @category Querying
* @param test Function to test nodes on.

@@ -58,3 +65,3 @@ * @param nodes Array of nodes to search.

*/
export declare function findAll(test: (elem: Element) => boolean, nodes: Node[]): Element[];
export declare function findAll(test: (elem: Element) => boolean, nodes: AnyNode[]): Element[];
//# sourceMappingURL=querying.d.ts.map

@@ -8,2 +8,3 @@ "use strict";

*
* @category Querying
* @param test Function to test nodes on.

@@ -26,2 +27,3 @@ * @param node Node to search. Will be included in the result set if it matches.

*
* @category Querying
* @param test Function to test nodes on.

@@ -56,5 +58,7 @@ * @param nodes Array of nodes to search.

*
* @category Querying
* @param test Function to test nodes on.
* @param nodes Array of nodes to search.
* @returns The first node in the array that passes `test`.
* @deprecated Use `Array.prototype.find` directly.
*/

@@ -68,2 +72,3 @@ function findOneChild(test, nodes) {

*
* @category Querying
* @param test Function to test nodes on.

@@ -93,5 +98,6 @@ * @param nodes Array of nodes to search.

/**
* @category Querying
* @param test Function to test nodes on.
* @param nodes Array of nodes to search.
* @returns Whether a tree of nodes contains at least one node passing a test.
* @returns Whether a tree of nodes contains at least one node passing the test.
*/

@@ -112,2 +118,3 @@ function existsOne(test, nodes) {

*
* @category Querying
* @param test Function to test nodes on.

@@ -133,1 +140,2 @@ * @param nodes Array of nodes to search.

exports.findAll = findAll;
//# sourceMappingURL=querying.js.map

@@ -1,20 +0,23 @@

import { Node } from "domhandler";
import { AnyNode } from "domhandler";
import { DomSerializerOptions } from "dom-serializer";
/**
* @category Stringify
* @deprecated Use the `dom-serializer` module directly.
* @param node Node to get the outer HTML of.
* @param options Options for serialization.
* @deprecated Use the `dom-serializer` module directly.
* @returns `node`'s outer HTML.
*/
export declare function getOuterHTML(node: Node | Node[], options?: DomSerializerOptions): string;
export declare function getOuterHTML(node: AnyNode | ArrayLike<AnyNode>, options?: DomSerializerOptions): string;
/**
* @category Stringify
* @deprecated Use the `dom-serializer` module directly.
* @param node Node to get the inner HTML of.
* @param options Options for serialization.
* @deprecated Use the `dom-serializer` module directly.
* @returns `node`'s inner HTML.
*/
export declare function getInnerHTML(node: Node, options?: DomSerializerOptions): string;
export declare function getInnerHTML(node: AnyNode, options?: DomSerializerOptions): string;
/**
* Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags.
*
* @category Stringify
* @deprecated Use `textContent` instead.

@@ -24,6 +27,7 @@ * @param node Node to get the inner text of.

*/
export declare function getText(node: Node | Node[]): string;
export declare function getText(node: AnyNode | AnyNode[]): string;
/**
* Get a node's text content.
*
* @category Stringify
* @param node Node to get the text content of.

@@ -33,6 +37,7 @@ * @returns `node`'s text content.

*/
export declare function textContent(node: Node | Node[]): string;
export declare function textContent(node: AnyNode | AnyNode[]): string;
/**
* Get a node's inner text.
*
* @category Stringify
* @param node Node to get the inner text of.

@@ -42,3 +47,3 @@ * @returns `node`'s inner text.

*/
export declare function innerText(node: Node | Node[]): string;
export declare function innerText(node: AnyNode | AnyNode[]): string;
//# sourceMappingURL=stringify.d.ts.map

@@ -11,5 +11,6 @@ "use strict";

/**
* @category Stringify
* @deprecated Use the `dom-serializer` module directly.
* @param node Node to get the outer HTML of.
* @param options Options for serialization.
* @deprecated Use the `dom-serializer` module directly.
* @returns `node`'s outer HTML.

@@ -22,5 +23,6 @@ */

/**
* @category Stringify
* @deprecated Use the `dom-serializer` module directly.
* @param node Node to get the inner HTML of.
* @param options Options for serialization.
* @deprecated Use the `dom-serializer` module directly.
* @returns `node`'s inner HTML.

@@ -37,2 +39,3 @@ */

*
* @category Stringify
* @deprecated Use `textContent` instead.

@@ -57,2 +60,3 @@ * @param node Node to get the inner text of.

*
* @category Stringify
* @param node Node to get the text content of.

@@ -76,2 +80,3 @@ * @returns `node`'s text content.

*
* @category Stringify
* @param node Node to get the inner text of.

@@ -92,1 +97,2 @@ * @returns `node`'s inner text.

exports.innerText = innerText;
//# sourceMappingURL=stringify.js.map

@@ -1,25 +0,27 @@

import { Node, Element, NodeWithChildren } from "domhandler";
import { AnyNode, ChildNode, Element, ParentNode } from "domhandler";
/**
* Get a node's children.
*
* @category Traversal
* @param elem Node to get the children of.
* @returns `elem`'s children, or an empty array.
*/
export declare function getChildren(elem: Node): Node[];
export declare function getParent(elem: Element): Element | null;
export declare function getParent(elem: Node): NodeWithChildren | null;
export declare function getChildren(elem: AnyNode): ChildNode[];
export declare function getParent(elem: AnyNode): ParentNode | null;
/**
* Gets an elements siblings, including the element itself.
*
* Attempts to get the children through the element's parent first.
* If we don't have a parent (the element is a root node),
* we walk the element's `prev` & `next` to get all remaining nodes.
* Attempts to get the children through the element's parent first. If we don't
* have a parent (the element is a root node), we walk the element's `prev` &
* `next` to get all remaining nodes.
*
* @category Traversal
* @param elem Element to get the siblings of.
* @returns `elem`'s siblings.
*/
export declare function getSiblings(elem: Node): Node[];
export declare function getSiblings(elem: AnyNode): AnyNode[];
/**
* Gets an attribute from an element.
*
* @category Traversal
* @param elem Element to check.

@@ -33,2 +35,3 @@ * @param name Attribute name to retrieve.

*
* @category Traversal
* @param elem Element to check.

@@ -42,2 +45,3 @@ * @param name Attribute name to look for.

*
* @category Traversal
* @param elem The element to get the name for.

@@ -50,13 +54,15 @@ * @returns The tag name of `elem`.

*
* @category Traversal
* @param elem The element to get the next sibling of.
* @returns `elem`'s next sibling that is a tag.
*/
export declare function nextElementSibling(elem: Node): Element | null;
export declare function nextElementSibling(elem: AnyNode): Element | null;
/**
* Returns the previous element sibling of a node.
*
* @category Traversal
* @param elem The element to get the previous sibling of.
* @returns `elem`'s previous sibling that is a tag.
*/
export declare function prevElementSibling(elem: Node): Element | null;
export declare function prevElementSibling(elem: AnyNode): Element | null;
//# sourceMappingURL=traversal.d.ts.map

@@ -5,6 +5,6 @@ "use strict";

var domhandler_1 = require("domhandler");
var emptyArray = [];
/**
* Get a node's children.
*
* @category Traversal
* @param elem Node to get the children of.

@@ -14,4 +14,3 @@ * @returns `elem`'s children, or an empty array.

function getChildren(elem) {
var _a;
return (_a = elem.children) !== null && _a !== void 0 ? _a : emptyArray;
return (0, domhandler_1.hasChildren)(elem) ? elem.children : [];
}

@@ -22,2 +21,3 @@ exports.getChildren = getChildren;

*
* @category Traversal
* @param elem Node to get the parent of.

@@ -33,6 +33,7 @@ * @returns `elem`'s parent node.

*
* Attempts to get the children through the element's parent first.
* If we don't have a parent (the element is a root node),
* we walk the element's `prev` & `next` to get all remaining nodes.
* Attempts to get the children through the element's parent first. If we don't
* have a parent (the element is a root node), we walk the element's `prev` &
* `next` to get all remaining nodes.
*
* @category Traversal
* @param elem Element to get the siblings of.

@@ -62,2 +63,3 @@ * @returns `elem`'s siblings.

*
* @category Traversal
* @param elem Element to check.

@@ -75,2 +77,3 @@ * @param name Attribute name to retrieve.

*
* @category Traversal
* @param elem Element to check.

@@ -89,2 +92,3 @@ * @param name Attribute name to look for.

*
* @category Traversal
* @param elem The element to get the name for.

@@ -100,2 +104,3 @@ * @returns The tag name of `elem`.

*
* @category Traversal
* @param elem The element to get the next sibling of.

@@ -115,2 +120,3 @@ * @returns `elem`'s next sibling that is a tag.

*
* @category Traversal
* @param elem The element to get the previous sibling of.

@@ -127,1 +133,2 @@ * @returns `elem`'s previous sibling that is a tag.

exports.prevElementSibling = prevElementSibling;
//# sourceMappingURL=traversal.js.map
{
"name": "domutils",
"version": "2.8.0",
"version": "3.0.0",
"description": "Utilities for working with htmlparser2's dom",

@@ -13,2 +13,7 @@ "author": "Felix Boehm <me@feedic.com>",

"types": "lib/index.d.ts",
"module": "lib/esm/index.js",
"exports": {
"require": "./lib/index.js",
"import": "./lib/esm/index.js"
},
"files": [

@@ -27,4 +32,5 @@ "lib/**/*"

"prettier": "prettier \"**/*.{ts,md,json,yml}\" --ignore-path .gitignore",
"build": "tsc",
"build:docs": "typedoc --hideGenerator --exclude \"**/*+(index|.spec).ts\" src",
"build": "npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --sourceRoot https://raw.githubusercontent.com/fb55/domutils/$(git rev-parse HEAD)/src/",
"build:esm": "npm run build:cjs -- --module esnext --target es2019 --outDir lib/esm && echo '{\"type\":\"module\"}' > lib/esm/package.json",
"prepare": "npm run build"

@@ -41,24 +47,28 @@ },

"dependencies": {
"dom-serializer": "^1.0.1",
"domelementtype": "^2.2.0",
"domhandler": "^4.2.0"
"dom-serializer": "^2.0.0",
"domelementtype": "^2.3.0",
"domhandler": "^5.0.1"
},
"devDependencies": {
"@types/jest": "^27.0.1",
"@types/node": "^16.7.2",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-jsdoc": "^36.0.8",
"htmlparser2": "~7.0.0",
"jest": "^27.1.0",
"prettier": "^2.0.5",
"ts-jest": "^27.0.5",
"typedoc": "^0.21.6",
"typescript": "^4.4.2"
"@types/jest": "^27.4.1",
"@types/node": "^17.0.25",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jsdoc": "^39.2.7",
"htmlparser2": "~7.2.0",
"jest": "^27.5.1",
"prettier": "^2.6.2",
"ts-jest": "^27.1.4",
"typedoc": "^0.22.15",
"typescript": "^4.6.3"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node"
"testEnvironment": "node",
"coverageProvider": "v8",
"moduleNameMapper": {
"^(.*)\\.js$": "$1"
}
},

@@ -65,0 +75,0 @@ "prettier": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc