UNPKG

wikiparser-node

Version:

A Node.js parser for MediaWiki markup with AST

66 lines (65 loc) 1.97 kB
import type { AstNodes, Token } from '../internal'; declare type ElementConstructor = abstract new (...args: any[]) => { readonly childNodes: readonly AstNodes[]; detach?: () => void; }; export interface ElementLike { /** all child elements / 全部非文本子节点 */ readonly children: Token[]; /** first child element / 首位非文本子节点 */ readonly firstElementChild: Token | undefined; /** last child element / 末位非文本子节点 */ readonly lastElementChild: Token | undefined; /** number of child elements / 非文本子节点总数 */ readonly childElementCount: number; /** * Get the first descendant that matches the selector * * 符合选择器的第一个后代节点 * @param selector selector / 选择器 */ querySelector<T = Token>(selector: string): T | undefined; /** * Get all descendants that match the selector * * 符合选择器的所有后代节点 * @param selector selector / 选择器 */ querySelectorAll<T = Token>(selector: string): T[]; /** * Escape `=` and `|` * * 转义 `=` 和 `|` * @since v1.18.3 */ escape(): void; /** * Get all descendants of the types * * 类型选择器 * @param types token types / 节点类型 */ getElementByTypes<T = Token>(types: string): T | undefined; /** * Get the first descendant with the id * * id选择器 * @param id id名 */ getElementById<T = Token>(id: string): T | undefined; /** * Get all descendants with the class * * 类选择器 * @param className class name / 类名之一 */ getElementsByClassName<T = Token>(className: string): T[]; /** * Get all descendants with the tag name * * 标签名选择器 * @param tag tag name / 标签名 */ getElementsByTagName<T = Token>(tag: string): T[]; } /** @ignore */