MCPcopy
hub / github.com/angular/angular / getAttrsForDirectiveMatching

Function getAttrsForDirectiveMatching

packages/compiler/src/render3/view/util.ts:207–230  ·  view source on GitHub ↗

* Extract a map of properties to values for a given element or template node, which can be used * by the directive matching machinery. * * @param elOrTpl the element or template in question * @return an object set up for directive matching. For attributes on the element/template, this * object

(elOrTpl: t.Element | t.Template)

Source from the content-addressed store, hash-verified

205 * property name to an empty string.
206 */
207function getAttrsForDirectiveMatching(elOrTpl: t.Element | t.Template): {[name: string]: string} {
208 const attributesMap: {[name: string]: string} = {};
209
210 if (elOrTpl instanceof t.Template && elOrTpl.tagName !== 'ng-template') {
211 elOrTpl.templateAttrs.forEach((a) => (attributesMap[a.name] = ''));
212 } else {
213 elOrTpl.attributes.forEach((a) => {
214 if (!isI18nAttribute(a.name)) {
215 attributesMap[a.name] = a.value;
216 }
217 });
218
219 elOrTpl.inputs.forEach((i) => {
220 if (i.type === BindingType.Property || i.type === BindingType.TwoWay) {
221 attributesMap[i.name] = '';
222 }
223 });
224 elOrTpl.outputs.forEach((o) => {
225 attributesMap[o.name] = '';
226 });
227 }
228
229 return attributesMap;
230}

Callers 1

Calls 2

isI18nAttributeFunction · 0.90
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…