document.querySelector null Error
-
Hi, we’re running WP 6.5.5 and Smush 3.16.5. While debugging something unrelated, I noticed a Smush-related console error when a role that cannot access Smush in the WP Admin menu is updating content.
The message is: Uncaught TypeError: document.querySelector(…) is null
The URLs I’ve seen this on include:
https://(site-redacted)/wp-admin/post-new.php
https://(site-redacted)/wp-admin/edit.php?post_type=post
https://(site-redacted)/wp-admin/post.php?post=1234&action=editIn digging around, it appears to be a reference to a JS snippet that adds an event listener. It includes the line:
document.querySelector( ‘#toplevel_page_smush li:last-child a’ ).target=”_blank”;
Since this ID exists in the WP Admin menu only for higher-level users, it is sometimes null. Hoping you can fix this in a future release. Thanks!
Edited to add:
I did some further testing, creating a post, saving it as a draft, and publishing it, and on publishing I received two additional errors that are presumably related. The summary:
https://(site-redacted)/wp-json/wp/v2/users?context=view&who=authors&per_page=50&_fields=id,name&_locale=user
rest_forbidden_who
Sorry, you are not allowed to query users by this parameter.
403https://(site-redacted)/wp-json/wp/v2/blocks?context=edit&per_page=100&_locale=user
rest_forbidden_context
Sorry, you are not allowed to edit posts in this post type.
403The related request info was empty. When I deactivate Smush and repeat the process I stepped through in creating, saving, and publishing, these errors are no longer generated. Again, this is a lower-level (custom) role that has Editor-level access to posts, but only to posts. Despite the errors, the items do save/publish.
The page I need help with: [log in to see the link]
- The topic ‘document.querySelector null Error’ is closed to new replies.