版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

50 lines
1.2 KiB

  1. import HTMLElement from '../nodes/html-element/HTMLElement';
  2. import Node from '../nodes/node/Node';
  3. /**
  4. * Custom elements registry.
  5. */
  6. export default class CustomElementRegistry {
  7. _registry: {
  8. [k: string]: {
  9. elementClass: typeof HTMLElement;
  10. extends: string;
  11. };
  12. };
  13. _callbacks: {
  14. [k: string]: (() => void)[];
  15. };
  16. /**
  17. * Defines a custom element class.
  18. *
  19. * @param tagName Tag name of element.
  20. * @param elementClass Element class.
  21. * @param [options] Options.
  22. * @param options.extends
  23. */
  24. define(tagName: string, elementClass: typeof HTMLElement, options?: {
  25. extends: string;
  26. }): void;
  27. /**
  28. * Returns a defined element class.
  29. *
  30. * @param tagName Tag name of element.
  31. * @param HTMLElement Class defined.
  32. */
  33. get(tagName: string): typeof HTMLElement;
  34. /**
  35. * Upgrades a custom element directly, even before it is connected to its shadow root.
  36. *
  37. * Not implemented yet.
  38. *
  39. * @param _root Root node.
  40. */
  41. upgrade(_root: Node): void;
  42. /**
  43. * When defined.
  44. *
  45. * @param tagName Tag name of element.
  46. * @returns Promise.
  47. */
  48. whenDefined(tagName: string): Promise<void>;
  49. }