UNPKG

@ryusei/code

Version:

<div align="center"> <a href="https://code.ryuseijs.com"> <img alt="RyuseiCode" src="https://code.ryuseijs.com/images/svg/logo.svg" width="70"> </a>

22 lines (17 loc) 491 B
import { isUndefined } from '../../type/type'; export function text( node: Node ): string; export function text( node: Node, text: string ): void; /** * Sets or gets a text content of the provided node. * * @param node - A node to get or set a text. * @param text - Optional. A text to set. */ export function text( node: Node, text?: string ): string | void { if ( node ) { if ( isUndefined( text ) ) { return node.textContent; } node.textContent = text; } }