From c06f7ee0a40255214c477e13d9b956a7e07c2900 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sat, 14 Oct 2023 15:05:55 +0800 Subject: postcss,(plugins): nanocss, postcss-preset-env --- node_modules/domutils/lib/esm/stringify.js | 81 ++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 node_modules/domutils/lib/esm/stringify.js (limited to 'node_modules/domutils/lib/esm/stringify.js') diff --git a/node_modules/domutils/lib/esm/stringify.js b/node_modules/domutils/lib/esm/stringify.js new file mode 100644 index 00000000..8fa46029 --- /dev/null +++ b/node_modules/domutils/lib/esm/stringify.js @@ -0,0 +1,81 @@ +import { isTag, isCDATA, isText, hasChildren, isComment, } from "domhandler"; +import renderHTML from "dom-serializer"; +import { ElementType } from "domelementtype"; +/** + * @category Stringify + * @deprecated Use the `dom-serializer` module directly. + * @param node Node to get the outer HTML of. + * @param options Options for serialization. + * @returns `node`'s outer HTML. + */ +export function getOuterHTML(node, options) { + return renderHTML(node, options); +} +/** + * @category Stringify + * @deprecated Use the `dom-serializer` module directly. + * @param node Node to get the inner HTML of. + * @param options Options for serialization. + * @returns `node`'s inner HTML. + */ +export function getInnerHTML(node, options) { + return hasChildren(node) + ? node.children.map((node) => getOuterHTML(node, options)).join("") + : ""; +} +/** + * Get a node's inner text. Same as `textContent`, but inserts newlines for `
` tags. Ignores comments. + * + * @category Stringify + * @deprecated Use `textContent` instead. + * @param node Node to get the inner text of. + * @returns `node`'s inner text. + */ +export function getText(node) { + if (Array.isArray(node)) + return node.map(getText).join(""); + if (isTag(node)) + return node.name === "br" ? "\n" : getText(node.children); + if (isCDATA(node)) + return getText(node.children); + if (isText(node)) + return node.data; + return ""; +} +/** + * Get a node's text content. Ignores comments. + * + * @category Stringify + * @param node Node to get the text content of. + * @returns `node`'s text content. + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent} + */ +export function textContent(node) { + if (Array.isArray(node)) + return node.map(textContent).join(""); + if (hasChildren(node) && !isComment(node)) { + return textContent(node.children); + } + if (isText(node)) + return node.data; + return ""; +} +/** + * Get a node's inner text, ignoring `