Replace className.indexOf with classList.contains (#1422)
* Compile rlt styles * Replace className.indexOf with classList.contains * Fix the composer comand * Update js/navigation.js Co-authored-by: Ismail El Korchi <ismail.elkorchi@gmail.com> * Update js/navigation.js Co-authored-by: Ismail El Korchi <ismail.elkorchi@gmail.com> * Update js/navigation.js Co-authored-by: Ismail El Korchi <ismail.elkorchi@gmail.com> Co-authored-by: Ismail El Korchi <ismail.elkorchi@gmail.com>
This commit is contained in:
parent
50ce93c7cd
commit
cf4410cb1f
3 changed files with 24 additions and 23 deletions
|
@ -25,12 +25,12 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
|
||||
if ( ! menu.classList.contains( 'nav-menu' ) ) {
|
||||
menu.className += ' nav-menu';
|
||||
}
|
||||
|
||||
button.onclick = function() {
|
||||
if ( -1 !== container.className.indexOf( 'toggled' ) ) {
|
||||
if ( container.classList.contains( 'toggled' ) ) {
|
||||
container.className = container.className.replace( ' toggled', '' );
|
||||
button.setAttribute( 'aria-expanded', 'false' );
|
||||
} else {
|
||||
|
@ -65,10 +65,10 @@
|
|||
var self = this;
|
||||
|
||||
// Move up through the ancestors of the current link until we hit .nav-menu.
|
||||
while ( -1 === self.className.indexOf( 'nav-menu' ) ) {
|
||||
while ( ! self.classList.contains( 'nav-menu' ) ) {
|
||||
// On li elements toggle the class .focus.
|
||||
if ( 'li' === self.tagName.toLowerCase() ) {
|
||||
if ( -1 !== self.className.indexOf( 'focus' ) ) {
|
||||
if ( self.classList.contains( 'focus' ) ) {
|
||||
self.className = self.className.replace( ' focus', '' );
|
||||
} else {
|
||||
self.className += ' focus';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue