const route = computed(() => router.resolve(unref(props.to)))
const activeRecordIndex = computed<number>(() => {
- let { matched } = route.value
- let { length } = matched
+ const { matched } = route.value
+ const { length } = matched
const routeMatched: RouteRecord | undefined = matched[length - 1]
- let currentMatched = currentRoute.matched
+ const currentMatched = currentRoute.matched
if (!routeMatched || !currentMatched.length) return -1
- let index = currentMatched.findIndex(
+ const index = currentMatched.findIndex(
isSameRouteRecord.bind(null, routeMatched)
)
if (index > -1) return index
// possible parent record
- let parentRecordPath = getOriginalPath(
+ const parentRecordPath = getOriginalPath(
matched[length - 2] as RouteRecord | undefined
)
return (
outer: RouteLocation['params'],
inner: RouteLocation['params']
): boolean {
- for (let key in inner) {
- let innerValue = inner[key]
- let outerValue = outer[key]
+ for (const key in inner) {
+ const innerValue = inner[key]
+ const outerValue = outer[key]
if (typeof innerValue === 'string') {
if (innerValue !== outerValue) return false
} else {
[K2 in Exclude<keyof T, K[number]>]: T[K2]
}
- for (let key in obj) {
+ for (const key in obj) {
if (!keys.includes(key as any)) {
// @ts-expect-error
ret[key] = obj[key]
`"() => import('./MyPage.vue')" ? This will break in ` +
`production if not fixed.`
)
- let promise = rawComponent
+ const promise = rawComponent
rawComponent = () => promise
} else if (
(rawComponent as any).__asyncLoader &&
if (isRouteComponent(rawComponent)) {
// __vccOpts is added by vue-class-component and contain the regular options
- let options: ComponentOptions =
+ const options: ComponentOptions =
(rawComponent as any).__vccOpts || rawComponent
const guard = options[guardType]
guard && guards.push(guardToPromiseFn(guard, to, from, record, name))
// replace the function with the resolved component
record.components[name] = resolvedComponent
// __vccOpts is added by vue-class-component and contain the regular options
- let options: ComponentOptions =
+ const options: ComponentOptions =
(resolvedComponent as any).__vccOpts || resolvedComponent
const guard = options[guardType]
return guard && guardToPromiseFn(guard, to, from, record, name)()
// pre decode the + into space
const searchParam = searchParams[i].replace(PLUS_RE, ' ')
// allow the = character
- let eqPos = searchParam.indexOf('=')
- let key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos))
- let value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1))
+ const eqPos = searchParam.indexOf('=')
+ const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos))
+ const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1))
if (key in query) {
// an extra variable for ts types
continue
}
// keep null values
- let values: LocationQueryValueRaw[] = Array.isArray(value)
+ const values: LocationQueryValueRaw[] = Array.isArray(value)
? value.map(v => v && encodeQueryValue(v))
: [value && encodeQueryValue(value)]
): LocationQuery {
const normalizedQuery: LocationQuery = {}
- for (let key in query) {
- let value = query[key]
+ for (const key in query) {
+ const value = query[key]
if (value !== undefined) {
normalizedQuery[key] = Array.isArray(value)
? value.map(v => (v == null ? null : '' + v))
let scrollToOptions: ScrollPositionCoordinates
if ('el' in position) {
- let positionEl = position.el
+ const positionEl = position.el
const isIdSelector =
typeof positionEl === 'string' && positionEl.startsWith('#')
/**
if (__DEV__ && typeof position.el === 'string') {
if (!isIdSelector || !document.getElementById(position.el.slice(1))) {
try {
- let foundEl = document.querySelector(position.el)
+ const foundEl = document.querySelector(position.el)
if (isIdSelector && foundEl) {
warn(
`The selector "${position.el}" should be passed as "el: document.querySelector('${position.el}')" because it starts with "#".`