UNPKG

hast-util-select

Version:

hast utility for `querySelector`, `querySelectorAll`, and `matches`

19 lines (17 loc) 379 B
/** * @import {AstId} from 'css-selector-parser' * @import {Element} from 'hast' */ /** * Check whether an element has an ID. * * @param {AstId} query * AST rule (with `ids`). * @param {Element} element * Element. * @returns {boolean} * Whether `element` matches `query`. */ export function id(query, element) { return element.properties.id === query.name }