MCPcopy Create free account
hub / github.com/angular/angular / _visitAttributesOf

Method _visitAttributesOf

packages/compiler/src/i18n/extractor_merger.ts:368–387  ·  view source on GitHub ↗
(el: html.Element)

Source from the content-addressed store, hash-verified

366
367 // looks for translatable attributes
368 private _visitAttributesOf(el: html.Element): void {
369 const explicitAttrNameToValue: {[k: string]: string} = {};
370 const implicitAttrNames: string[] = this._implicitAttrs[el.name] || [];
371
372 el.attrs
373 .filter((attr) => attr instanceof html.Attribute && attr.name.startsWith(_I18N_ATTR_PREFIX))
374 .forEach((attr) => {
375 explicitAttrNameToValue[attr.name.slice(_I18N_ATTR_PREFIX.length)] = (
376 attr as html.Attribute
377 ).value;
378 });
379
380 el.attrs.forEach((attr) => {
381 if (attr.name in explicitAttrNameToValue) {
382 this._addMessage([attr], explicitAttrNameToValue[attr.name]);
383 } else if (implicitAttrNames.some((name) => attr.name === name)) {
384 this._addMessage([attr]);
385 }
386 });
387 }
388
389 // add a translatable message
390 private _addMessage(ast: html.Node[], msgMeta?: string): i18n.Message | null {

Callers 1

_visitElementLikeMethod · 0.95

Calls 5

_addMessageMethod · 0.95
someMethod · 0.80
sliceMethod · 0.65
forEachMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected