Skip to content

Commit

Permalink
Fix #2127
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Aug 7, 2020
1 parent 0768b5c commit 0d99197
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 27 deletions.
61 changes: 35 additions & 26 deletions server/src/modes/template/tagProviders/routerTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,46 @@ import {
Priority
} from './common';

const u = undefined;

const routerTags = {
'router-link': new HTMLTagSpecification('Link to navigate user. The target location is specified with the to prop.', [
genAttribute('to', u, 'The target route of the link. It can be either a string or a location descriptor object.'),
genAttribute(
'replace',
u,
'Setting replace prop will call router.replace() instead of router.push() when clicked, so the navigation will not leave a history record.'
),
genAttribute(
'append',
u,
'Setting append prop always appends the relative path to the current path. For example, assuming we are navigating from /a to a relative link b, without append we will end up at /b, but with append we will end up at /a/b.'
),
genAttribute('tag', u, 'Specify which tag to render to, and it will still listen to click events for navigation.'),
genAttribute('active-class', u, 'Configure the active CSS class applied when the link is active.'),
genAttribute('exact', u, 'Force the link into "exact match mode".'),
genAttribute('event', u, 'Specify the event(s) that can trigger the link navigation.'),
genAttribute(
'exact-active-class',
u,
'Configure the active CSS class applied when the link is active with exact match.'
)
]),
'router-link': new HTMLTagSpecification(
'Link to navigate user. The target location is specified with the to prop.\n\n',
[
genAttribute(
'to',
undefined,
'The target route of the link. It can be either a string or a location descriptor object.'
),
genAttribute(
'replace',
undefined,
'Setting replace prop will call router.replace() instead of router.push() when clicked, so the navigation will not leave a history record.'
),
genAttribute(
'append',
'v',
'Setting append prop always appends the relative path to the current path. For example, assuming we are navigating from /a to a relative link b, without append we will end up at /b, but with append we will end up at /a/b.'
),
genAttribute(
'tag',
undefined,
'Specify which tag to render to, and it will still listen to click events for navigation.'
),
genAttribute('active-class', undefined, 'Configure the active CSS class applied when the link is active.'),
genAttribute('exact', 'v', 'Force the link into "exact match mode".'),
genAttribute('event', undefined, 'Specify the event(s) that can trigger the link navigation.'),
genAttribute(
'exact-active-class',
undefined,
'Configure the active CSS class applied when the link is active with exact match.'
)
]
),
'router-view': new HTMLTagSpecification(
'A functional component that renders the matched component for the given path. Components rendered in <router-view> can also contain its own <router-view>, which will render components for nested paths.',
'A functional component that renders the matched component for the given path. Components rendered in <router-view> can also contain its own <router-view>, which will render components for nested paths.\n\n\n\n[API Reference](https://router.vuejs.org/api/#router-link)',
[
genAttribute(
'name',
u,
undefined,
"When a <router-view> has a name, it will render the component with the corresponding name in the matched route record's components option"
)
]
Expand Down
14 changes: 13 additions & 1 deletion test/componentData/features/completion/basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import { position } from '../../../util';
import { position, sameLineRange } from '../../../util';
import { testCompletion } from '../../../completionHelper';
import { getDocUri } from '../../path';

describe('Should complete frameworks', () => {
describe('Should complete vue-router tags/attributes', () => {
const vueRouterUri = getDocUri('completion/VueRouter.vue');

it('completes vue-router tags', async () => {
await testCompletion(vueRouterUri, position(3, 5), ['router-link', 'router-view']);
});

it('completes vue-router attributes', async () => {
await testCompletion(vueRouterUri, position(2, 17), ['replace']);
});
});

describe('Should complete element-ui components (devDependency, loaded from bundled JSON)', () => {
const elementUri = getDocUri('completion/Element.vue');

Expand Down
6 changes: 6 additions & 0 deletions test/componentData/fixture/completion/VueRouter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<div>
<router-link ></router-link>
<
</div>
</template>

0 comments on commit 0d99197

Please sign in to comment.