Skip to content

Commit 5aca29c

Browse files
committed
Toolbar: Improvements to changes in [62282].
This updates the JavaScript based regular expression to be case-insensitive, which matches the corresponding PHP pattern. A defensive check has alos been added to avoid a `TypeError` if the admin bar is manipulated in a way that changes the path of the targeted element. Follow up to [62282]. Props westonruter. Fixes #65121. git-svn-id: https://develop.svn.wordpress.org/trunk@62320 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8a99228 commit 5aca29c

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 ) ).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)