Skip to content

Commit 1482c05

Browse files
committed
Update section.js
1 parent 4859426 commit 1482c05

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

docs/components/section.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@ import { scrollTargetIntoView } from '~/utils'
33

44
// --- Utility methods ---
55

6-
// Convert local links to router push or scrollIntoView
6+
// Convert local links to router push or scroll target into view
77
const linkToRouter = event => {
88
if (!event || event.type !== 'click') {
99
return
1010
}
11-
const target = event.target && event.target.closest ? event.target.closest('a[href]') : null
11+
const $target = event.target && event.target.closest ? event.target.closest('a[href]') : null
12+
// Early exit if click inside an example, not a link,
13+
// or default prevented or is a Vue instance
1214
if (
13-
!target ||
15+
!$target ||
1416
event.type !== 'click' ||
15-
target.__vue__ ||
16-
target.closest('.bd-example') ||
17-
target.closest('pre') ||
17+
$target.__vue__ ||
18+
$target.closest('.bd-example') ||
19+
$target.closest('pre') ||
1820
event.defaultPrevented
1921
) {
20-
// Early exit if click inside an example, not a link, or
21-
// default prevented or is a Vue instance
2222
return
2323
}
24-
const href = target.getAttribute('href')
24+
const href = $target.getAttribute('href')
2525
if (href && href.indexOf('/') === 0 && href.indexOf('//') !== 0) {
26-
// if local page-to-page-docs link, convert click to `$router.push()`
26+
// If local page-to-page-docs link, convert click to `$router.push()`
2727
event.preventDefault()
2828
if (typeof window !== 'undefined' && window.$nuxt) {
29-
// Since we are a functional component, we can't use this.$router
29+
// Since we are a functional component, we can't use `this.$router`
3030
window.$nuxt.$router.push(href)
3131
}
3232
} else if (href && href.indexOf('#') === 0) {
33-
// In page anchor link, so use scrollIntoView utility method
33+
// In page anchor link, so use `scrollTargetIntoView` utility method
3434
scrollTargetIntoView(event, href)
3535
}
3636
// Else, normal browser link handling (i.e. external links)

0 commit comments

Comments
 (0)