UNPKG

yoastseo

Version:

Yoast client-side content analysis

82 lines (77 loc) 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _TextContainer = _interopRequireDefault(require("../TextContainer")); var _Node = _interopRequireDefault(require("./Node")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** * A node at the end of the tree that may only contain formatting elements, * these include headings and paragraphs. * * @extends module:parsedPaper/structure.Node * * @memberOf module:parsedPaper/structure * * @abstract */ class LeafNode extends _Node.default { /** * Creates a new leaf node. * * @param {string} type The type of Node (should be unique for each child class of Node). * @param {Object} sourceCodeLocation The parse5 formatted location of the element inside of the source code. * * @returns {void} */ constructor(type, sourceCodeLocation) { super(type, sourceCodeLocation); /** * A container for keeping this leaf node's text. * @type {module:parsedPaper/structure.TextContainer} */ this.textContainer = new _TextContainer.default(); } /** * Retrieves the heading text (from the TextContainer). * * @returns {string} The text of the heading. */ get text() { return this.textContainer.text; } /** * Sets the heading text (via the TextContainer). * * @param {string} text The text to assign as the heading text. * * @returns {void} */ set text(text) { this.textContainer.text = text; } /** * Appends text to this leaf node. * * @param {string} text The text to append. * * @returns {void} */ appendText(text) { this.textContainer.appendText(text); } /** * Adds formatting and sets the formatting's parent to this leaf node. * * @param {FormattingElement} formatting The formatting to add. * * @returns {void} */ addFormatting(formatting) { formatting.parent = this; this.textContainer.formatting.push(formatting); } } var _default = exports.default = LeafNode; //# sourceMappingURL=LeafNode.js.map