globalScript.js 839 B

1234567891011121314151617181920212223242526
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.97
  5. */
  6. import { initThemeChangeEvent } from "./theme";
  7. /**
  8. * This file is imported in Stencil's `globalScript` config option.
  9. *
  10. * @see {@link https://stenciljs.com/docs/config#globalscript}
  11. */
  12. export default function () {
  13. const isBrowser = typeof window !== "undefined" &&
  14. typeof location !== "undefined" &&
  15. typeof document !== "undefined" &&
  16. window.location === location &&
  17. window.document === document;
  18. if (isBrowser) {
  19. if (document.readyState === "interactive") {
  20. initThemeChangeEvent();
  21. }
  22. else {
  23. document.addEventListener("DOMContentLoaded", () => initThemeChangeEvent(), { once: true });
  24. }
  25. }
  26. }