fix(language-service): provide hover for interpolation in attribute value (#35494)

I think the bug is introduced in my PR#34847. For example, 'model="{{title}}"', the attribute value cannot be parsed by 'parseTemplateBindings'.

PR Close #35494
This commit is contained in:
ivanwonder
2020-02-17 18:38:12 +08:00
committed by Miško Hevery
parent 54fd33fb80
commit 049f118c1b
2 changed files with 25 additions and 8 deletions

View File

@ -39,6 +39,16 @@ describe('hover', () => {
expect(toText(displayParts)).toBe('(property) MyComponent.name: string');
});
it('should be able to find an interpolated value in an attribute', () => {
mockHost.override(TEST_TEMPLATE, `<div string-model model="{{«title»}}"></div>`);
const marker = mockHost.getReferenceMarkerFor(TEST_TEMPLATE, 'title');
const quickInfo = ngLS.getQuickInfoAtPosition(TEST_TEMPLATE, marker.start);
expect(quickInfo).toBeTruthy();
const {textSpan, displayParts} = quickInfo !;
expect(textSpan).toEqual(marker);
expect(toText(displayParts)).toBe('(property) TemplateReference.title: string');
});
it('should be able to find a field in a attribute reference', () => {
const fileName = mockHost.addCode(`
@Component({