getElement.js 792 B

123456789101112131415161718192021222324
  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. var foundElement = document.getElementById(element);
  12. //>>includeStart('debug', pragmas.debug);
  13. if (foundElement === null) {
  14. throw new DeveloperError('Element with id "' + element + '" does not exist in the document.');
  15. }
  16. //>>includeEnd('debug');
  17. element = foundElement;
  18. }
  19. return element;
  20. }
  21. export default getElement;