getElement.js 693 B

1234567891011121314151617181920212223242526
  1. import DeveloperError from "../Core/DeveloperError.js";
  2. /**
  3. * If element is a string, look up the element in the DOM by ID. Otherwise return element.
  4. *
  5. * @private
  6. *
  7. * @exception {DeveloperError} Element with id "id" does not exist in the document.
  8. */
  9. function getElement(element) {
  10. if (typeof element === "string") {
  11. const foundElement = document.getElementById(element);
  12. //>>includeStart('debug', pragmas.debug);
  13. if (foundElement === null) {
  14. throw new DeveloperError(
  15. `Element with id "${element}" does not exist in the document.`
  16. );
  17. }
  18. //>>includeEnd('debug');
  19. element = foundElement;
  20. }
  21. return element;
  22. }
  23. export default getElement;