(template: string, enableSelectorless = false)
| 62 | } |
| 63 | |
| 64 | function parse(template: string, enableSelectorless = false): ParseResult { |
| 65 | const position = template.indexOf('¦'); |
| 66 | if (position < 0) { |
| 67 | throw new Error(`Template "${template}" does not contain the cursor`); |
| 68 | } |
| 69 | template = template.replace('¦', ''); |
| 70 | const templateUrl = '/foo'; |
| 71 | return { |
| 72 | ...parseTemplate(template, templateUrl, { |
| 73 | // Set `leadingTriviaChars` and `preserveWhitespaces` such that whitespace is not stripped |
| 74 | // and fully accounted for in source spans. Without these flags the source spans can be |
| 75 | // inaccurate. |
| 76 | // Note: template parse options should be aligned with the `diagNodes` in |
| 77 | // `ComponentDecoratorHandler._parseTemplate`. |
| 78 | leadingTriviaChars: [], |
| 79 | preserveWhitespaces: true, |
| 80 | alwaysAttemptHtmlToR3AstConversion: true, |
| 81 | enableSelectorless, |
| 82 | }), |
| 83 | position, |
| 84 | }; |
| 85 | } |
| 86 | |
| 87 | describe('getTargetAtPosition for template AST', () => { |
| 88 | it('should locate incomplete tag', () => { |
no test coverage detected
searching dependent graphs…