virtual-document.d.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. declare const enum ENodeType {
  2. ELEMENT = 1,
  3. TEXT = 3,
  4. }
  5. export interface IFakeDomNode {
  6. readonly nodeType: ENodeType;
  7. readonly tagName: string;
  8. readonly style?: {
  9. cssText?: string;
  10. };
  11. readonly data?: string;
  12. readonly innerText?: string;
  13. readonly parentNode: IFakeDomNode | null;
  14. readonly nextSibling: IFakeDomNode | null;
  15. readonly textContent: string;
  16. readonly innerHTML: string;
  17. readonly firstChild: IFakeDomNode;
  18. readonly childNodes: IFakeDomNode[];
  19. appendChild: (child: IFakeDomNode) => void;
  20. insertBefore: (child: IFakeDomNode, before: IFakeDomNode) => void;
  21. addEventListener: (type: string, listener: (e: any) => void) => void;
  22. removeEventListener: (type: string, listener: (e: any) => void) => void;
  23. setAttribute: (name: string, value: string) => void;
  24. removeAttribute: (name: string) => void;
  25. removeChild: (child: IFakeDomNode) => void;
  26. }
  27. declare function throwNotImplemented(...anyParam: any[]): void;
  28. export declare const virtualDocument: {
  29. createElement: (tagName: string, options?: unknown) => IFakeDomNode;
  30. createTextNode: (text: string) => IFakeDomNode;
  31. createElementNS: typeof throwNotImplemented;
  32. };