Uncaught TypeError: Cannot read property 'closest' of undefined

Hi there,

A client site https://mojocoffees.com/ just started showing this error:

Uncaught TypeError: Cannot read property ‘closest’ of undefined
at Object. (x.js?ver=7.1.2:1)
at cs.0ce70e6.js:1
at Array.forEach ()
at Object.apply (cs.0ce70e6.js:1)
at before (cs.0ce70e6.js:145)
at HTMLBodyElement. (cs.0ce70e6.js:145)
3

x.js?ver=7.1.2:1

The set up is that I have 2 wordpress menus - they look the same but the homepage one is a single page nav with anchor links to content-bands and the subnavs link to the other pages. The subpage nav is a regular nav.

All was working fine for several years but it suddenly stopped working and threw this error.

Any ideas to help? Wordpress and X are up to date.

Thanks,

Alice

I updated X to the latest version and that seems to have solved the js error.

Now the navigation works fine on safari but it’s not working on Chrome. I see these errors in console:

DevTools failed to load SourceMap: Could not load content for chrome-extension://hdokiejnpimakedhajhdlcegeplioahd/sourcemaps/onloadwff.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
DevTools failed to load SourceMap: Could not load content for https://mojocoffees.com/wp-content/themes/x/framework/dist/js/site/x.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load SourceMap: Could not load content for https://mojocoffees.com/wp-content/plugins/cornerstone/assets/dist/js/site/cs.0ce70e6.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load SourceMap: Could not load content for https://mojocoffees.com/wp-content/plugins/store-locator-le/css/blank_mapfix.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

I also notice that the edit menus page takes a long time to load and dev tools shows many instances of this error, just on the wordpress edit menus page, not on pages or posts or any other settings:

[DOM] Found 2 elements with non-unique id #edit-menu-item-anchor_graphic_image_width-1752: (More info: https://goo.gl/9p2vKq) <input type=​"text" id=​"edit-menu-item-anchor_graphic_image_width-1752" class=​"widefat edit-menu-item-anchor_graphic_image_width-1752" name=​"menu-item-anchor_graphic_image_width[1752]​" value>​ <input type=​"text" id=​"edit-menu-item-anchor_graphic_image_width-1752" class=​"widefat edit-menu-item-anchor_graphic_image_width-1752" name=​"menu-item-anchor_graphic_image_width[1752]​" value>​
nav-menus.php:1 [DOM] Found 2 elements with non-unique id #edit-menu-item-anchor_graphic_image_width-1792: (More info: https://goo.gl/9p2vKq) <input type=​"text" id=​"edit-menu-item-anchor_graphic_image_width-1792" class=​"widefat edit-menu-item-anchor_graphic_image_width-1792" name=​"menu-item-anchor_graphic_image_width[1792]​" value>​ <input type=​"text" id=​"edit-menu-item-anchor_graphic_image_width-1792" class=​"widefat edit-menu-item-anchor_graphic_image_width-1792" name=​"menu-item-anchor_graphic_image_width[1792]​" value>​
nav-menus.php:1 [DOM] Found 2 elements with non-unique id #edit-menu-item-anchor_graphic_image_width-1807: (More info: https://goo.gl/9p2vKq) <input type=​"text" id=​"edit-menu-item-anchor_graphic_image_width-1807" class=​"widefat edit-menu-item-anchor_graphic_image_width-1807" name=​"menu-item-anchor_graphic_image_width[1807]​" value>​ <input type=​"text" id=​"edit-menu-item-anchor_graphic_image_width-1807" class=​"widefat edit-menu-item-anchor_graphic_image_width-1807" name=​"menu-item-anchor_graphic_image_width[1807]​" value>​
nav-menus.php:1 [DOM] Found 2 elements with non-unique id #edit-menu-item-anchor_graphic_image_width-1792: (More info: https://goo.gl/9p2vKq) <input type=​"text" id=​"edit-menu-item-anchor_graphic_image_width-1792" class=​"widefat edit-menu-item-anchor_graphic_image_width-1792" name=​"menu-item-anchor_graphic_image_width[1792]​" value>​ <input type=​"text" id=​"edit-menu-item-anchor_graphic_image_width-1792" class=​"widefat edit-menu-item-anchor_graphic_image_width-1792" name=​"menu-item-anchor_graphic_image_width[1792]​" value>​
nav-menus.php:1 [DOM] Found 2 elements with non-unique id #edit-menu-item-anchor_graphic_image_width-1807: (More info: https://goo.gl/9p2vKq) <input type=​"text" id=​"edit-menu-item-anchor_graphic_image_width-1807" class=​"widefat edit-menu-item-anchor_graphic_image_width-1807" name=​"menu-item-anchor_graphic_image_width[1807]​" value>​ <input type=​"text" id=​"edit-menu-item-anchor_graphic_image_width-1807" class=​"widefat edit-menu-item-anchor_graphic_image_width-1807" name=​"menu-item-anchor_graphic_image_width[1807]​" value>​

One other thing I have noticed. On Chrome the menu items that aren’t working are just the ones with submenu items.

Hi @gatehousedesign,

Thank you for reaching out to us. I tested your menu in Chrome using Windows OS and I find it working without any issue. Did you clear your cache after updating the theme? After doing the updates, always remember to clear all caches (if you are using WP Rocket, WP SuperCache or W3 Total Cache) including your browser’s cache when updating so that the code from the latest release is always in use. This will help you to avoid any potential errors.

The other console warnings you shared are just warnings that can be ignore and they won’t effect your site’s functionality. I’d recommend you to clear all caches including your browser’s cache and check the menu again.

If you still face problems, please see https://theme.co/docs/common-issues

Let us know how this goes!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.