getElement.js 864 B

12345678910111213141516171819202122232425262728293031
  1. /*global define*/
  2. define([
  3. '../Core/DeveloperError'
  4. ], function(
  5. DeveloperError) {
  6. "use strict";
  7. /**
  8. * If element is a string, look up the element in the DOM by ID. Otherwise return element.
  9. *
  10. * @private
  11. *
  12. * @exception {DeveloperError} Element with id "id" does not exist in the document.
  13. */
  14. var getElement = function(element) {
  15. if (typeof element === 'string') {
  16. var foundElement = document.getElementById(element);
  17. //>>includeStart('debug', pragmas.debug);
  18. if (foundElement === null) {
  19. throw new DeveloperError('Element with id "' + element + '" does not exist in the document.');
  20. }
  21. //>>includeEnd('debug');
  22. element = foundElement;
  23. }
  24. return element;
  25. };
  26. return getElement;
  27. });