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

Function getAttrsForDirectiveMatching

packages/compiler/src/render3/view/util.ts:201–224  ·  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

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

Callers 1

Calls 2

isI18nAttributeFunction · 0.90
forEachMethod · 0.45

Tested by

no test coverage detected