We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 72874f4 commit c9474adCopy full SHA for c9474ad
1 file changed
src/js/utils/isMobileNav.js
@@ -8,6 +8,19 @@ import getCssVar from './getCssVar'
8
* @example isMobileNav() => true; !isMobileNav() => false
9
*/
10
export default function isMobileNav(breakpointVar = '--breakpoint-mobile-to-desktop-nav') {
11
- const breakpoint = parseInt(getCssVar(breakpointVar), 10)
+ const rawValue = getCssVar(breakpointVar)
12
+
13
+ if (!rawValue) {
14
+ console.warn(`isMobileNav: Variable ${breakpointVar} is empty or undefined. Returning false.`)
15
+ return false
16
+ }
17
18
+ const breakpoint = parseInt(rawValue, 10)
19
20
+ if (isNaN(breakpoint)) {
21
+ console.warn(`isMobileNav: Could not parse "${rawValue}" as a number.`)
22
23
24
25
return window.matchMedia(`(max-width: ${breakpoint - 1}px)`).matches
26
}
0 commit comments