How does Angular compiler process multiple template reference variables with the same name -


i want start contributing angular, have idea feature, want template compiler issue warning if template contains 2 template variables of same name. think managed close source files responsible: https://github.com/angular/angular/blob/master/packages/compiler/src/view_compiler/view_compiler.ts couldn't quite find spot, understandably. there here can guide me ?

you need _assertnoreferenceduplicationontemplate method:

  _assertnoreferenceduplicationontemplate(result: templateast[], errors): void {     const existingreferences: string[] = [];      result.filter(element => !!(<any>element).references)        .foreach(element => (<any>element).references.foreach((reference: referenceast) => {           const name = reference.name;           if (existingreferences.indexof(name) < 0) {             existingreferences.push(name);           } else {             const error = new templateparseerror(                 `reference "#${name}" defined several times`, reference.sourcespan,                 parseerrorlevel.error);             errors.push(error);           }         }));   } 

angular compiler creates ast 1 node type being elementast has references property:

export class elementast implements templateast {   constructor(       public name: string,       public references: referenceast[],       ... 

and property checked in _assertnoreferenceduplicationontemplate function , if found error generated.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -