@cagovweb/state-template 6.5.0 → 6.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var StateTemplateNpmPackageVersion="6.5.0";
1
+ var StateTemplateNpmPackageVersion="6.5.1";
2
2
  /*!
3
3
  * Bootstrap v5.3.3 (https://getbootstrap.com/)
4
4
  * Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
@@ -8383,6 +8383,17 @@ window.addEventListener("load", () => {
8383
8383
  pagenav.appendChild(pagenavUL);
8384
8384
  pagenav.setAttribute("aria-labelledby", "on-this-page-navigation-label");
8385
8385
  }
8386
+
8387
+ // Scroll to hash solution
8388
+ const hashLocation = window.location;
8389
+ if (hashLocation.hash) {
8390
+ // Trigger a hashchange to ensure hash scrolling works
8391
+ setTimeout(() => {
8392
+ const currentHash = hashLocation.hash;
8393
+ hashLocation.hash += "_"; // Remove the hash temporarily
8394
+ hashLocation.hash = currentHash; // Reapply the hash
8395
+ }, 500);
8396
+ }
8386
8397
  }); // call out the function on the page load
8387
8398
 
8388
8399
  //@ts-check
@@ -8915,15 +8926,61 @@ window.addEventListener("load", () => {
8915
8926
  });
8916
8927
 
8917
8928
  window.addEventListener("DOMContentLoaded", () => {
8918
- //POLYFILL for CSS nesting
8919
- if (!CSS.supports("selector(&)")) {
8920
- // If CSS nesting not supported load alternative CSS file
8921
- const link = /** @type {HTMLLinkElement} */ (
8922
- document.getElementById("main-stylesheet")
8929
+ const csscorelink = /** @type {HTMLcsscorelinkElement} */ (
8930
+ document.querySelector("link[rel='stylesheet'][href*='cagov.core.']")
8931
+ );
8932
+
8933
+ /**
8934
+ * Checks if media queries are supported by the browser.
8935
+ * @returns {boolean} True if media queries are supported, otherwise false.
8936
+ */
8937
+ function mediaQueriesSupported() {
8938
+ return (
8939
+ typeof window.matchMedia != "undefined" ||
8940
+ typeof window.msMatchMedia != "undefined"
8923
8941
  );
8924
- if (link) {
8925
- link.href = link.href.replace("min", "flat");
8926
- console.log("POLYFILL: Using FLAT CSS instead of Nested");
8942
+ }
8943
+
8944
+ /**
8945
+ * Tests if media query range notation is supported by the browser.
8946
+ * @returns {boolean} True if range notation is supported, otherwise false.
8947
+ */
8948
+ function testMediaQueryRangeNotation() {
8949
+ return window.matchMedia("(width >= 0px)").matches;
8950
+ }
8951
+
8952
+ /**
8953
+ * Loads an alternative CSS file if CSS nesting or media query range notation is not supported.
8954
+ */
8955
+ function loadAlternativeCSS() {
8956
+ if (csscorelink) {
8957
+ csscorelink.removeAttribute("integrity");
8958
+ csscorelink.href = csscorelink.href.replace(
8959
+ /cagov\.core(\.min)?\.css/,
8960
+ "cagov.core.flat.css"
8961
+ );
8962
+ console.log(`POLYFILL: Using new CSS file - ${csscorelink.href}`);
8927
8963
  }
8928
8964
  }
8965
+
8966
+ // POLYFILL for CSS nesting and media query range notation
8967
+ /**
8968
+ * Checks if CSS nesting is supported by the browser.
8969
+ */
8970
+ if (!CSS.supports("selector(&)")) {
8971
+ console.log("POLYFILL: Nested CSS is not supported");
8972
+
8973
+ loadAlternativeCSS();
8974
+ }
8975
+
8976
+ /**
8977
+ * Checks if media queries are supported by the browser.
8978
+ */
8979
+ if (!mediaQueriesSupported() || !testMediaQueryRangeNotation()) {
8980
+ console.log(
8981
+ "POLYFILL: Media query range notation (<, <=, >, >=) is not supported."
8982
+ );
8983
+
8984
+ loadAlternativeCSS();
8985
+ }
8929
8986
  });