angular-estree-parser
Advanced tools
Comparing version
@@ -356,20 +356,8 @@ import * as angular from '@angular/compiler'; | ||
if (node instanceof angular.TemplateLiteralElement) { | ||
const templateLiteral = options.parent; | ||
const elementIndex = templateLiteral.elements.indexOf(node); | ||
const { elements } = options.parent; | ||
const elementIndex = elements.indexOf(node); | ||
const isFirst = elementIndex === 0; | ||
const isLast = elementIndex === templateLiteral.elements.length - 1; | ||
// The `TemplateLiteralElement` don't have correct location information | ||
const start = isFirst | ||
? templateLiteral.sourceSpan.start + 1 | ||
: node.sourceSpan.start; | ||
let end; | ||
if (isLast) { | ||
end = templateLiteral.sourceSpan.end - 1; | ||
} | ||
else { | ||
const nextExpression = templateLiteral.expressions[elementIndex]; | ||
// TODO: Support search multiple characters in `getCharacterLastIndex()` | ||
// FIXME: Search `${` instead | ||
end = this.getCharacterLastIndex('$', nextExpression.sourceSpan.start); | ||
} | ||
const isLast = elementIndex === elements.length - 1; | ||
const end = node.sourceSpan.end - (isLast ? 1 : 0); | ||
const start = node.sourceSpan.start + (isFirst ? 1 : 0); | ||
const raw = this.text.slice(start, end); | ||
@@ -376,0 +364,0 @@ return this.#create({ |
{ | ||
"name": "angular-estree-parser", | ||
"version": "11.1.0", | ||
"version": "11.1.1", | ||
"description": "A parser that converts Angular source code into an ESTree-compatible form", | ||
@@ -30,6 +30,6 @@ "keywords": [], | ||
"devDependencies": { | ||
"@angular/compiler": "19.2.1", | ||
"@angular/compiler": "19.2.2", | ||
"@babel/code-frame": "7.26.2", | ||
"@babel/parser": "7.26.9", | ||
"@babel/types": "7.26.9", | ||
"@babel/parser": "7.26.10", | ||
"@babel/types": "7.26.10", | ||
"@types/babel__code-frame": "7.0.6", | ||
@@ -54,3 +54,3 @@ "@types/node": "22.13.10", | ||
"peerDependencies": { | ||
"@angular/compiler": "^19.0.0" | ||
"@angular/compiler": ">=19.2.2" | ||
}, | ||
@@ -57,0 +57,0 @@ "engines": { |
45685
-1.23%989
-1.2%