diff --git a/packages/language-service/src/locate_symbol.ts b/packages/language-service/src/locate_symbol.ts index 6780c68bc9..b4967a1415 100644 --- a/packages/language-service/src/locate_symbol.ts +++ b/packages/language-service/src/locate_symbol.ts @@ -123,8 +123,8 @@ function locateSymbol(ast: TemplateAst, path: TemplateAstPath, info: AstResult): }, visitElementProperty(ast) { attributeValueSymbol(ast.value); }, visitAttr(ast) { - const element = path.head; - if (!element || !(element instanceof ElementAst)) return; + const element = path.first(ElementAst); + if (!element) return; // Create a mapping of all directives applied to the element from their selectors. const matcher = new SelectorMatcher(); for (const dir of element.directives) { diff --git a/packages/language-service/test/hover_spec.ts b/packages/language-service/test/hover_spec.ts index 77bf77abe0..75a6592343 100644 --- a/packages/language-service/test/hover_spec.ts +++ b/packages/language-service/test/hover_spec.ts @@ -109,7 +109,8 @@ describe('hover', () => { }); it('should be able to find a reference to a directive', () => { - const content = mockHost.override(TEST_TEMPLATE, `
`); + const content = + mockHost.override(TEST_TEMPLATE, `
`); const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'cursor'); const quickInfo = ngLS.getQuickInfoAtPosition(TEST_TEMPLATE, marker.start); expect(quickInfo).toBeDefined();