refactor: CSS.escape may not be supported by some browsers

This commit is contained in:
ciencia 2022-04-18 19:50:20 -04:00 committed by alistair3149
parent 98c6f2753a
commit f1aee0bdf6
No known key found for this signature in database
GPG key ID: 94D081060FD3DD9C

View file

@ -196,7 +196,8 @@ function initTabber( tabber, count ) {
var targetHash = new mw.Uri( location.href ).fragment;
// Switch to the first tab if no targetHash or no tab is detected
if ( !targetHash || !tabList.querySelector( '#tab-' + CSS.escape( targetHash ) ) ) {
// TODO: Remove the polyfill with CSS.escape when we are dropping IE support
if ( !targetHash || !tabList.querySelector( '#tab-' + targetHash.replace( /[^a-zA-Z0-9-_]/g, '\\$&' ) ) ) {
targetHash = tabList.firstElementChild.getAttribute( 'id' ).substring( 4 );
}