fix(language-service): use the HtmlAst to get the span of HTML tag (#36371)

The HTML tag may include `-` (e.g. `app-root`), so use the `HtmlAst` to get the span.

PR Close #36371
This commit is contained in:
ivanwonder
2020-04-01 21:29:01 +08:00
committed by Kara Erickson
parent 96a3de6364
commit 81195a238b
2 changed files with 17 additions and 7 deletions

View File

@ -670,18 +670,18 @@ describe('completions', () => {
@Component({
selector: 'foo-component',
template: \`
<di~{div}></div>
<test-comp~{test-comp}></test-comp>
\`,
})
export class FooComponent {}
`);
const location = mockHost.getLocationMarkerFor(fileName, 'div');
const location = mockHost.getLocationMarkerFor(fileName, 'test-comp');
const completions = ngLS.getCompletionsAtPosition(fileName, location.start)!;
expect(completions).toBeDefined();
const completion = completions.entries.find(entry => entry.name === 'div')!;
const completion = completions.entries.find(entry => entry.name === 'test-comp')!;
expect(completion).toBeDefined();
expect(completion.kind).toBe('html element');
expect(completion.replacementSpan).toEqual({start: location.start - 2, length: 2});
expect(completion.kind).toBe('component');
expect(completion.replacementSpan).toEqual({start: location.start - 9, length: 9});
});
it('should work for bindings', () => {