max-sub-level => sub-max-level

This commit is contained in:
qingwei.li 2016-12-31 11:50:30 +08:00
commit e932ff66b9
6 changed files with 34 additions and 18 deletions

View file

@ -66,18 +66,20 @@ export function activeLink (dom, activeParent) {
if (!dom) return
let target
;[].slice.call(dom.querySelectorAll('a')).forEach(node => {
if (node.href === host && !target) {
activeParent
? node.parentNode.setAttribute('class', 'active')
: node.setAttribute('class', 'active')
target = node
} else {
activeParent
? node.parentNode.removeAttribute('class')
: node.removeAttribute('class')
}
})
;[].slice.call(dom.querySelectorAll('a'))
.sort((a, b) => b.href.length - a.href.length)
.forEach(node => {
if (host.indexOf(node.href) === 0 && !target) {
activeParent
? node.parentNode.setAttribute('class', 'active')
: node.setAttribute('class', 'active')
target = node
} else {
activeParent
? node.parentNode.removeAttribute('class')
: node.removeAttribute('class')
}
})
return target
}