Skip to content

Instantly share code, notes, and snippets.

@matthewstokeley
Created August 3, 2019 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewstokeley/762b8561ed5d5fc7565e60a562c87a2a to your computer and use it in GitHub Desktop.
Save matthewstokeley/762b8561ed5d5fc7565e60a562c87a2a to your computer and use it in GitHub Desktop.
const _containsActiveClass = function( _el, i ) {
for ( ; i < _el.children.length; i++ ) {
if ( _el.children[ i ].children[ 0 ] ) {
return _containsActiveClass( _el.children[ i ], 0 )
}
return _el.children[ i ].classList.contains( ACTIVE_CLASS )
}
}
const _findNestedSiblings = ( _el ) => {
let matches = []
let parent = _el.parentNode
for ( let i = 0; i < parent.children.length; i++ ) {
let child = parent.children[ i ]
if (child !== _el &&
child.nodeType === 1) {
if ( child.children[0] &&
child.children[0].tagName === "A" ) {
matches.push( child.children[0] )
}
}
}
return matches
}
const _filterChildElement = function( _el, item ) {
for ( let i = 0; i < _el.children.length; i++ ) {
if ( _el.children[ i ] === item) {
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment