From: nandi95 <41805560+nandi95@users.noreply.github.com> Date: Wed, 3 Aug 2022 08:03:12 +0000 (+0100) Subject: docs: spelling fixes in doc blocks (#1495) X-Git-Tag: v4.1.4~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c1f7cd769e7194a14092c47b2638482744d7d021;p=thirdparty%2Fvuejs%2Frouter.git docs: spelling fixes in doc blocks (#1495) --- diff --git a/packages/router/src/RouterLink.ts b/packages/router/src/RouterLink.ts index 9bd9568f..702efa14 100644 --- a/packages/router/src/RouterLink.ts +++ b/packages/router/src/RouterLink.ts @@ -65,7 +65,9 @@ export interface RouterLinkProps extends RouterLinkOptions { */ exactActiveClass?: string /** - * Value passed to the attribute `aria-current` when the link is exact active. Defaults to "page" + * Value passed to the attribute `aria-current` when the link is exact active. + * + * @defaultValue 'page' */ ariaCurrentValue?: | 'page' @@ -236,7 +238,7 @@ export const RouterLinkImpl = /*#__PURE__*/ defineComponent({ : null, href: link.href, // this would override user added attrs but Vue will still add - // the listener so we end up triggering both + // the listener, so we end up triggering both onClick: link.navigate, class: elClass.value, }, @@ -254,7 +256,7 @@ export const RouterLinkImpl = /*#__PURE__*/ defineComponent({ export const RouterLink: _RouterLinkI = RouterLinkImpl as any /** - * Typed version of the `RouterLink` component. Its generic defaults to the typed router so it can be inferred + * Typed version of the `RouterLink` component. Its generic defaults to the typed router, so it can be inferred * automatically for JSX. * * @internal diff --git a/packages/router/src/RouterView.ts b/packages/router/src/RouterView.ts index d107e231..ad136f60 100644 --- a/packages/router/src/RouterView.ts +++ b/packages/router/src/RouterView.ts @@ -102,7 +102,7 @@ export const RouterViewImpl = /*#__PURE__*/ defineComponent({ // this will update the instance for new instances as well as reused // instances when navigating to a new route to.instances[name] = instance - // the component instance is reused for a different route or name so + // the component instance is reused for a different route or name, so // we copy any saved update or leave guards. With async setup, the // mounting component will mount before the matchedRoute changes, // making instance === oldInstance, so we check if guards have been diff --git a/packages/router/src/encoding.ts b/packages/router/src/encoding.ts index 248a7506..e4670708 100644 --- a/packages/router/src/encoding.ts +++ b/packages/router/src/encoding.ts @@ -7,7 +7,7 @@ import { warn } from './warning' * On top of that, the RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.2) * defines some extra characters to be encoded. Most browsers do not encode them * in encodeURI https://github.com/whatwg/url/issues/369, so it may be safer to - * also encode `!'()*`. Leaving unencoded only ASCII alphanumeric(`a-zA-Z0-9`) + * also encode `!'()*`. Leaving un-encoded only ASCII alphanumeric(`a-zA-Z0-9`) * plus `-._~`. This extra safety should be applied to query by patching the * string returned by encodeURIComponent encodeURI also encodes `[\]^`. `\` * should be encoded to avoid ambiguity. Browsers (IE, FF, C) transform a `\` @@ -32,7 +32,7 @@ export const PLUS_RE = /\+/g // %2B * application/x-www-form-urlencoded * (https://url.spec.whatwg.org/#urlencoded-parsing) and most browsers seems lo * leave the plus character as is in queries. To be more flexible, we allow the - * plus character on the query but it can also be manually encoded by the user. + * plus character on the query, but it can also be manually encoded by the user. * * Resources: * - https://url.spec.whatwg.org/#urlencoded-parsing diff --git a/packages/router/src/errors.ts b/packages/router/src/errors.ts index afae094a..5f7aa995 100644 --- a/packages/router/src/errors.ts +++ b/packages/router/src/errors.ts @@ -13,7 +13,7 @@ import { assign } from './utils' * @internal */ export const enum ErrorTypes { - // they must be literals to be used as values so we can't write + // they must be literals to be used as values, so we can't write // 1 << 2 MATCHER_NOT_FOUND = 1, NAVIGATION_GUARD_REDIRECT = 2, diff --git a/packages/router/src/globalExtensions.ts b/packages/router/src/globalExtensions.ts index ae9121c4..a9391b2e 100644 --- a/packages/router/src/globalExtensions.ts +++ b/packages/router/src/globalExtensions.ts @@ -27,7 +27,7 @@ declare module '@vue/runtime-core' { : NavigationGuardWithThis /** - * Guard called whenever the route that renders this component has changed but + * Guard called whenever the route that renders this component has changed, but * it is reused for the new route. This allows you to guard for changes in * params, the query or the hash. * diff --git a/packages/router/src/history/common.ts b/packages/router/src/history/common.ts index 3476777a..0abf4815 100644 --- a/packages/router/src/history/common.ts +++ b/packages/router/src/history/common.ts @@ -4,7 +4,7 @@ import { removeTrailingSlash } from '../location' export type HistoryLocation = string /** * Allowed variables in HTML5 history state. Note that pushState clones the state - * passed and does not accept everything: e.g it doesn't accept symbols, nor + * passed and does not accept everything: e.g.: it doesn't accept symbols, nor * functions as values. It also ignores Symbols as keys. * * @internal @@ -74,8 +74,8 @@ export type ValueContainer = { value: T } export interface RouterHistory { /** * Base path that is prepended to every url. This allows hosting an SPA at a - * subfolder of a domain like `example.com/subfolder` by having a `base` of - * `/subfolder` + * sub-folder of a domain like `example.com/sub-folder` by having a `base` of + * `/sub-folder` */ readonly base: string /** diff --git a/packages/router/src/history/html5.ts b/packages/router/src/history/html5.ts index 5949ce9c..bc4531f9 100644 --- a/packages/router/src/history/html5.ts +++ b/packages/router/src/history/html5.ts @@ -114,7 +114,7 @@ function useHistoryListeners( } function listen(callback: NavigationCallback) { - // setup the listener and prepare teardown callbacks + // set up the listener and prepare teardown callbacks listeners.push(callback) const teardown = () => { @@ -142,7 +142,7 @@ function useHistoryListeners( window.removeEventListener('beforeunload', beforeUnloadListener) } - // setup the listeners and prepare teardown callbacks + // set up the listeners and prepare teardown callbacks window.addEventListener('popstate', popStateHandler) window.addEventListener('beforeunload', beforeUnloadListener) @@ -192,7 +192,7 @@ function useHistoryStateNavigation(base: string) { // the length is off by one, we need to decrease it position: history.length - 1, replaced: true, - // don't add a scroll as the user may have an anchor and we want + // don't add a scroll as the user may have an anchor, and we want // scrollBehavior to be triggered without a saved position scroll: null, }, @@ -206,7 +206,7 @@ function useHistoryStateNavigation(base: string) { replace: boolean ): void { /** - * if a base tag is provided and we are on a normal domain, we have to + * if a base tag is provided, and we are on a normal domain, we have to * respect the provided `base` attribute because pushState() will use it and * potentially erase anything before the `#` like at * https://github.com/vuejs/router/issues/685 where a base of diff --git a/packages/router/src/history/memory.ts b/packages/router/src/history/memory.ts index c4d07eef..c2ec8194 100644 --- a/packages/router/src/history/memory.ts +++ b/packages/router/src/history/memory.ts @@ -12,7 +12,7 @@ import { } from './common' /** - * Creates a in-memory based history. The main purpose of this history is to handle SSR. It starts in a special location that is nowhere. + * Creates an in-memory based history. The main purpose of this history is to handle SSR. It starts in a special location that is nowhere. * It's up to the user to replace that location with the starter location by either calling `router.push` or `router.replace`. * * @param base - Base applied to all urls, defaults to '/' diff --git a/packages/router/src/location.ts b/packages/router/src/location.ts index 18ca5339..24fa764a 100644 --- a/packages/router/src/location.ts +++ b/packages/router/src/location.ts @@ -34,7 +34,7 @@ export const removeTrailingSlash = (path: string) => path.replace(TRAILING_SLASH_RE, '') /** - * Transforms an URI into a normalized history location + * Transforms a URI into a normalized history location * * @param parseQuery * @param location - URI to normalize @@ -104,8 +104,7 @@ export function stringifyURL( } /** - * Strips off the base from the beginning of a location.pathname in a non - * case-sensitive way. + * Strips off the base from the beginning of a location.pathname in a non-case-sensitive way. * * @param pathname - location.pathname * @param base - base to strip off @@ -225,11 +224,11 @@ export function resolveRelativePath(to: string, from: string): string { if (segment === '.') continue // go up in the from array if (segment === '..') { - // we can't go below zero but we still need to increment toPosition + // we can't go below zero, but we still need to increment toPosition if (position > 1) position-- // continue } - // we reached a non relative path, we stop here + // we reached a non-relative path, we stop here else break } diff --git a/packages/router/src/matcher/index.ts b/packages/router/src/matcher/index.ts index fc39dec2..a1f584e8 100644 --- a/packages/router/src/matcher/index.ts +++ b/packages/router/src/matcher/index.ts @@ -134,13 +134,13 @@ export function createRouterMatcher( ) } - // create the object before hand so it can be passed to children + // create the object beforehand, so it can be passed to children matcher = createRouteRecordMatcher(normalizedRecord, parent, options) if (__DEV__ && parent && path[0] === '/') checkMissingParamsInAbsolutePath(matcher, parent) - // if we are an alias we must tell the original record that we exist + // if we are an alias we must tell the original record that we exist, // so we can be removed if (originalRecord) { originalRecord.alias.push(matcher) @@ -170,7 +170,7 @@ export function createRouterMatcher( } // if there was no original record, then the first one was not an alias and all - // other alias (if any) need to reference this record when adding children + // other aliases (if any) need to reference this record when adding children originalRecord = originalRecord || matcher // TODO: add normalized records for more flexibility @@ -373,7 +373,7 @@ function normalizeRecordProps( record: RouteRecordRaw ): Record { const propsObject = {} as Record - // props does not exist on redirect records but we can set false directly + // props does not exist on redirect records, but we can set false directly const props = record.props || false if ('component' in record) { propsObject.default = props diff --git a/packages/router/src/matcher/pathParserRanker.ts b/packages/router/src/matcher/pathParserRanker.ts index ed99c613..5c8e0757 100644 --- a/packages/router/src/matcher/pathParserRanker.ts +++ b/packages/router/src/matcher/pathParserRanker.ts @@ -52,23 +52,31 @@ export interface PathParser { */ export interface _PathParserOptions { /** - * Makes the RegExp case sensitive. Defaults to false + * Makes the RegExp case-sensitive. + * + * @defaultValue false */ sensitive?: boolean /** - * Should we disallow a trailing slash. Defaults to false + * Whether to disallow a trailing slash or not. + * + * @defaultValue false */ strict?: boolean /** - * Should the RegExp match from the beginning by prepending a `^` to it. Defaults to true + * Should the RegExp match from the beginning by prepending a `^` to it. * @internal + * + * @defaultValue true */ start?: boolean /** - * Should the RegExp match until the end by appending a `$` to it. Defaults to true + * Should the RegExp match until the end by appending a `$` to it. + * + * @defaultValue true */ end?: boolean } @@ -78,7 +86,7 @@ export type PathParserOptions = Pick< 'end' | 'sensitive' | 'strict' > -// default pattern for a param: non greedy everything but / +// default pattern for a param: non-greedy everything but / const BASE_PARAM_PATTERN = '[^/]+?' const BASE_PATH_PARSER_OPTIONS: Required<_PathParserOptions> = { @@ -136,7 +144,7 @@ export function tokensToParser( if (options.strict && !segment.length) pattern += '/' for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) { const token = segment[tokenIndex] - // resets the score if we are inside a sub segment /:a-other-:b + // resets the score if we are inside a sub-segment /:a-other-:b let subSegmentScore: number = PathScore.Segment + (options.sensitive ? PathScore.BonusCaseSensitive : 0) diff --git a/packages/router/src/matcher/types.ts b/packages/router/src/matcher/types.ts index a4288610..6693a3d7 100644 --- a/packages/router/src/matcher/types.ts +++ b/packages/router/src/matcher/types.ts @@ -73,7 +73,7 @@ export interface RouteRecordNormalized { * views. */ instances: Record - // can only be of of the same type as this record + // can only be of the same type as this record /** * Defines if this record is the alias of another one. This property is * `undefined` if the record is the original one. diff --git a/packages/router/src/navigationGuards.ts b/packages/router/src/navigationGuards.ts index 4f8b519f..148a51f2 100644 --- a/packages/router/src/navigationGuards.ts +++ b/packages/router/src/navigationGuards.ts @@ -67,7 +67,7 @@ export function onBeforeRouteLeave(leaveGuard: NavigationGuard) { if (!activeRecord) { __DEV__ && warn( - 'No active route record was found when calling `onBeforeRouteLeave()`. Make sure you call this function inside of a component child of . Maybe you called it inside of App.vue?' + 'No active route record was found when calling `onBeforeRouteLeave()`. Make sure you call this function inside a component child of . Maybe you called it inside of App.vue?' ) return } @@ -99,7 +99,7 @@ export function onBeforeRouteUpdate(updateGuard: NavigationGuard) { if (!activeRecord) { __DEV__ && warn( - 'No active route record was found when calling `onBeforeRouteUpdate()`. Make sure you call this function inside of a component child of . Maybe you called it inside of App.vue?' + 'No active route record was found when calling `onBeforeRouteUpdate()`. Make sure you call this function inside a component child of . Maybe you called it inside of App.vue?' ) return } @@ -352,7 +352,7 @@ export function isRouteComponent( } /** - * Ensures a route is loaded so it can be passed as o prop to ``. + * Ensures a route is loaded, so it can be passed as o prop to ``. * * @param route - resolved route to load */ diff --git a/packages/router/src/router.ts b/packages/router/src/router.ts index 430dd840..e2d392cd 100644 --- a/packages/router/src/router.ts +++ b/packages/router/src/router.ts @@ -174,7 +174,7 @@ export interface RouterOptions extends PathParserOptions { */ linkExactActiveClass?: string /** - * Default class applied to non active {@link RouterLink}. If none is provided, + * Default class applied to non-active {@link RouterLink}. If none is provided, * `router-link-inactive` will be applied. */ // linkInactiveClass?: string @@ -235,7 +235,7 @@ export interface Router { /** * Returns the {@link RouteLocation | normalized version} of a * {@link RouteLocationRaw | route location}. Also includes an `href` property - * that includes any existing `base`. By default the `currentLocation` used is + * that includes any existing `base`. By default, the `currentLocation` used is * `route.currentRoute` and should only be overridden in advanced use cases. * * @param to - Raw route location to resolve @@ -492,7 +492,7 @@ export function createRouter(options: RouterOptions): Router { delete targetParams[key] } } - // pass encoded values to the matcher so it can produce encoded path and fullPath + // pass encoded values to the matcher, so it can produce encoded path and fullPath matcherLocation = assign({}, rawLocation, { params: encodeParams(rawLocation.params), }) @@ -510,7 +510,7 @@ export function createRouter(options: RouterOptions): Router { ) } - // decoding them) the matcher might have merged current location params so + // the matcher might have merged current location params, so // we need to run the decoding again matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params)) @@ -730,7 +730,7 @@ export function createRouter(options: RouterOptions): Router { // keep options assign( { - // preserve an existing replace but allow the redirect to override it + // preserve an existing replacement but allow the redirect to override it replace, }, locationAsObject(failure.to), @@ -1001,7 +1001,7 @@ export function createRouter(options: RouterOptions): Router { // Here we could call if (info.delta) routerHistory.go(-info.delta, // false) but this is bug prone as we have no way to wait the // navigation to be finished before calling pushWithRedirect. Using - // a setTimeout of 16ms seems to work but there is not guarantee for + // a setTimeout of 16ms seems to work but there is no guarantee for // it to work on every browser. So instead we do not restore the // history entry and trigger a new navigation as requested by the // navigation guard. @@ -1015,7 +1015,7 @@ export function createRouter(options: RouterOptions): Router { ) .then(failure => { // manual change in hash history #916 ending up in the URL not - // changing but it was changed by the manual url change, so we + // changing, but it was changed by the manual url change, so we // need to manually change it ourselves if ( isNavigationFailure( diff --git a/packages/router/src/types/index.ts b/packages/router/src/types/index.ts index b92bb338..ef5b7f1d 100644 --- a/packages/router/src/types/index.ts +++ b/packages/router/src/types/index.ts @@ -165,7 +165,7 @@ export interface _RouteLocationBase export interface RouteLocationNormalizedLoaded extends _RouteLocationBase { /** * Array of {@link RouteLocationMatched} containing only plain components (any - * lazy-loaded components have been loaded and were replaced inside of the + * lazy-loaded components have been loaded and were replaced inside the * `components` object) so it can be directly used to display routes. It * cannot contain redirect records either */ @@ -420,7 +420,7 @@ export const START_LOCATION_NORMALIZED: RouteLocationNormalizedLoaded = { redirectedFrom: undefined, } -// make matched non enumerable for easy printing +// make matched non-enumerable for easy printing // NOTE: commented for tests at RouterView.spec // Object.defineProperty(START_LOCATION_NORMALIZED, 'matched', { // enumerable: false, @@ -456,7 +456,7 @@ export interface MatcherLocation { params: RouteParams /** - * Merged `meta` properties from all of the matched route records. + * Merged `meta` properties from all the matched route records. */ meta: RouteMeta