MCPcopy Index your code
hub / github.com/angular/angular / _visitAttributesOf

Method _visitAttributesOf

packages/compiler/src/i18n/extractor_merger.ts:396–416  ·  view source on GitHub ↗
(el: html.Element | html.Component)

Source from the content-addressed store, hash-verified

394
395 // looks for translatable attributes
396 private _visitAttributesOf(el: html.Element | html.Component): void {
397 const explicitAttrNameToValue: {[k: string]: string} = {};
398 const implicitAttrNames: string[] =
399 this._implicitAttrs[el instanceof html.Component ? el.tagName || '' : el.name] || [];
400
401 el.attrs
402 .filter((attr) => attr instanceof html.Attribute && attr.name.startsWith(_I18N_ATTR_PREFIX))
403 .forEach((attr) => {
404 explicitAttrNameToValue[attr.name.slice(_I18N_ATTR_PREFIX.length)] = (
405 attr as html.Attribute
406 ).value;
407 });
408
409 el.attrs.forEach((attr) => {
410 if (attr.name in explicitAttrNameToValue) {
411 this._addMessage([attr], explicitAttrNameToValue[attr.name]);
412 } else if (implicitAttrNames.some((name) => attr.name === name)) {
413 this._addMessage([attr]);
414 }
415 });
416 }
417
418 // add a translatable message
419 private _addMessage(ast: html.Node[], msgMeta?: string): i18n.Message | null {

Callers 1

_visitElementLikeMethod · 0.95

Calls 4

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

Tested by

no test coverage detected