UNPKG

yoastseo

Version:

Yoast client-side content analysis

35 lines (33 loc) 795 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = innerText; var _lodash = require("lodash"); /** * @typedef {import("../structure").Node} Node * @typedef {import("../structure").Text} Text */ /** * Gathers the text content of the given node. * * @param {Node|Text} node The node to gather the text content from. * * @returns {string} The text content. */ function innerText(node) { let text = ""; if (!(0, _lodash.isEmpty)(node.childNodes)) { node.childNodes.forEach(child => { if (child.name === "#text") { text += child.value; } else if (child.name === "br") { text += "\n"; } else { text += innerText(child); } }); } return text; } //# sourceMappingURL=innerText.js.map