legacy.d.ts 2.1 KB

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