[wp-trac] [WordPress Trac] #52773: Twenty Twenty-One Theme - "Can't read property querySelector of null" console error
WordPress Trac
noreply at wordpress.org
Thu Mar 11 09:35:48 UTC 2021
#52773: Twenty Twenty-One Theme - "Can't read property querySelector of null"
console error
--------------------------+-----------------------------
Reporter: sushmak | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version:
Severity: normal | Keywords: needs-patch
Focuses: |
--------------------------+-----------------------------
I am getting this console error while designing a custom header on my site
- https://share.getcloudapp.com/Z4u68O9Z
`primary-navigation.js?ver=1.2:172 Uncaught TypeError: Cannot read
property 'querySelectorAll' of null`
This error is from Primary-navigation.js from the Twenty Twenty-One theme.
I am using an [Elementor](https://wordpress.org/plugins/elementor/) plugin
to design a custom header.
I have added a navigation menu in the header and the below error appears
in the console of my Elementor editor.
I debugged the issue further and seems like this issue is due to the below
code in the Twenty Twenty-One theme.
File Path - `wp-content\themes\twentytwentyone\assets\js\primary-
navigation.js`
Line No. - 170
Code - https://share.getcloudapp.com/jkueN9NK
In the above code `site-navigation` ID is not present in the navigation
menu. To fix this we need to add a null check before applying
queryselectall().
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52773>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list