Skip to content

Commit c39fb03

Browse files
committed
Prevent TypeError when admin bar is manipulated.
1 parent c301ceb commit c39fb03

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/wp-includes/admin-bar.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,12 @@ function wp_admin_bar_command_palette_menu( WP_Admin_Bar $wp_admin_bar ): void {
971971
*/
972972
$function = <<<'JS'
973973
( applePattern, appleOSLabel ) => {
974-
if ( ( new RegExp( applePattern, 'i' ) ).test( navigator.userAgent ) ) {
975-
document.querySelector( '#wp-admin-bar-command-palette .ab-label kbd' ).textContent = appleOSLabel;
974+
if ( ! ( new RegExp( applePattern, 'i' ) ).test( navigator.userAgent ) ) {
975+
return;
976+
}
977+
const kbd = document.querySelector( '#wp-admin-bar-command-palette .ab-label kbd' );
978+
if ( kbd ) {
979+
kbd.textContent = appleOSLabel;
976980
}
977981
}
978982
JS;

0 commit comments

Comments
 (0)