UNPKG

yoastseo

Version:

Yoast client-side content analysis

21 lines (19 loc) 644 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getParentNode; /** * @typedef {import("../structure").Node} Node */ /** * Retrieves the parent node for a given node. * @param {Node} tree The current tree. * @param {Node} node The current node. * @returns {Node} The parent node. */ function getParentNode(tree, node) { // Includes a fallback so that if a parent node cannot be found for an implicit paragraph, we use the current node as the parent node. return tree.findAll(treeNode => treeNode.childNodes?.includes(node))[0] || node; } //# sourceMappingURL=getParentNode.js.map