@@ -4,12 +4,7 @@ import {
44 VariableBinding as NGVariableBinding ,
55} from '@angular/compiler' ;
66import { type Context } from './context.js' ;
7- import {
8- type InputNode ,
9- type OutputNode ,
10- transform ,
11- transformSpan ,
12- } from './transform.js' ;
7+ import transformNode from './transform-node.js' ;
138import type {
149 NGMicrosyntax ,
1510 NGMicrosyntaxAs ,
@@ -22,12 +17,15 @@ import type {
2217 RawNGSpan ,
2318} from './types.js' ;
2419import { NG_PARSE_TEMPLATE_BINDINGS_FAKE_PREFIX } from './parser.js' ;
25- import { toLowerCamelCase } from './utils.js' ;
20+ import { toLowerCamelCase , transformSpan } from './utils.js' ;
2621
27- export function transformTemplateBindings (
28- rawTemplateBindings : ng . TemplateBinding [ ] ,
29- context : Context ,
30- ) : NGMicrosyntax {
22+ function transformTemplateBindings ( {
23+ expressions : rawTemplateBindings ,
24+ context,
25+ } : {
26+ expressions : ng . TemplateBinding [ ] ;
27+ context : Context ;
28+ } ) : NGMicrosyntax {
3129 rawTemplateBindings . forEach ( fixTemplateBindingSpan ) ;
3230
3331 const [ firstTemplateBinding ] = rawTemplateBindings ;
@@ -62,7 +60,7 @@ export function transformTemplateBindings(
6260 ) ;
6361 const updateSpanEnd = < T extends NGNode > ( node : T , end : number ) : T => ( {
6462 ...node ,
65- ...transformSpan ( { start : node . start ! , end } , context ) ,
63+ ...transformSpan ( { start : node . start ! , end } , context . text ) ,
6664 } ) ;
6765 const updateExpressionAlias = ( expression : NGMicrosyntaxExpression ) => ( {
6866 ...updateSpanEnd ( expression , alias . end ) ,
@@ -180,21 +178,21 @@ export function transformTemplateBindings(
180178 }
181179 }
182180
183- function _t < T extends OutputNode > ( n : InputNode ) {
184- return transform ( n , context ) as T & RawNGSpan ;
181+ function _t < T extends NGNode > ( n : ng . AST ) {
182+ return transformNode ( n , context ) as T ;
185183 }
186184
187- function _c < T extends OutputNode > (
185+ function _c < T extends NGNode > (
188186 t : T [ 'type' ] ,
189187 n : Partial < T > ,
190188 span : RawNGSpan ,
191189 stripSpaces = true ,
192190 ) {
193191 return {
194192 type : t ,
195- ...transformSpan ( span , context , stripSpaces ) ,
193+ ...transformSpan ( span , context . text , { processSpan : stripSpaces } ) ,
196194 ...n ,
197- } as T & { start : number ; end : number ; range : [ number , number ] } ;
195+ } as T ;
198196 }
199197
200198 function removePrefix ( string : string ) {
@@ -271,3 +269,5 @@ export function transformTemplateBindings(
271269 } ;
272270 }
273271}
272+
273+ export { transformTemplateBindings } ;
0 commit comments