legacy.d.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { AnyNode, Element } from "domhandler";
  2. import type { ElementType } from "domelementtype";
  3. /**
  4. * An object with keys to check elements against. If a key is `tag_name`,
  5. * `tag_type` or `tag_contains`, it will check the value against that specific
  6. * value. Otherwise, it will check an attribute with the key's name.
  7. *
  8. * @category Legacy Query Functions
  9. */
  10. export interface TestElementOpts {
  11. tag_name?: string | ((name: string) => boolean);
  12. tag_type?: string | ((name: string) => boolean);
  13. tag_contains?: string | ((data?: string) => boolean);
  14. [attributeName: string]: undefined | string | ((attributeValue: string) => boolean);
  15. }
  16. /**
  17. * @category Legacy Query Functions
  18. * @param options An object describing nodes to look for.
  19. * @param node The element to test.
  20. * @returns Whether the element matches the description in `options`.
  21. */
  22. export declare function testElement(options: TestElementOpts, node: AnyNode): boolean;
  23. /**
  24. * @category Legacy Query Functions
  25. * @param options An object describing nodes to look for.
  26. * @param nodes Nodes to search through.
  27. * @param recurse Also consider child nodes.
  28. * @param limit Maximum number of nodes to return.
  29. * @returns All nodes that match `options`.
  30. */
  31. export declare function getElements(options: TestElementOpts, nodes: AnyNode | AnyNode[], recurse: boolean, limit?: number): AnyNode[];
  32. /**
  33. * @category Legacy Query Functions
  34. * @param id The unique ID attribute value to look for.
  35. * @param nodes Nodes to search through.
  36. * @param recurse Also consider child nodes.
  37. * @returns The node with the supplied ID.
  38. */
  39. export declare function getElementById(id: string | ((id: string) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean): Element | null;
  40. /**
  41. * @category Legacy Query Functions
  42. * @param tagName Tag name to search for.
  43. * @param nodes Nodes to search through.
  44. * @param recurse Also consider child nodes.
  45. * @param limit Maximum number of nodes to return.
  46. * @returns All nodes with the supplied `tagName`.
  47. */
  48. export declare function getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean, limit?: number): Element[];
  49. /**
  50. * @category Legacy Query Functions
  51. * @param type Element type to look for.
  52. * @param nodes Nodes to search through.
  53. * @param recurse Also consider child nodes.
  54. * @param limit Maximum number of nodes to return.
  55. * @returns All nodes with the supplied `type`.
  56. */
  57. export declare function getElementsByTagType(type: ElementType | ((type: ElementType) => boolean), nodes: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[];
  58. //# sourceMappingURL=legacy.d.ts.map