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

Function setUpAttributes

packages/core/src/render3/util/attrs_utils.ts:42–80  ·  view source on GitHub ↗
(renderer: Renderer, native: RElement, attrs: TAttributes)

Source from the content-addressed store, hash-verified

40 * @returns the index value that was last accessed in the attributes array
41 */
42export function setUpAttributes(renderer: Renderer, native: RElement, attrs: TAttributes): number {
43 let i = 0;
44 while (i < attrs.length) {
45 const value = attrs[i];
46 if (typeof value === 'number') {
47 // only namespaces are supported. Other value types (such as style/class
48 // entries) are not supported in this function.
49 if (value !== AttributeMarker.NamespaceURI) {
50 break;
51 }
52
53 // we just landed on the marker value ... therefore
54 // we should skip to the next entry
55 i++;
56
57 const namespaceURI = attrs[i++] as string;
58 const attrName = attrs[i++] as string;
59 const attrVal = attrs[i++] as string;
60 renderer.setAttribute(native, attrName, attrVal, namespaceURI);
61 } else {
62 // attrName is string;
63 const attrName = value as string;
64 const attrVal = attrs[++i];
65 // Standard attributes
66 if (isAnimationProp(attrName)) {
67 renderer.setProperty(native, attrName, attrVal);
68 } else {
69 renderer.setAttribute(native, attrName, attrVal as string);
70 }
71 i++;
72 }
73 }
74
75 // another piece of code may iterate over the same attributes array. Therefore
76 // it may be helpful to return the exact spot where the attributes array exited
77 // whether by running into an unsupported marker or if all the static values were
78 // iterated over.
79 return i;
80}
81
82/**
83 * Test whether the given value is a marker that indicates that the following

Callers 1

setupStaticAttributesFunction · 0.90

Calls 3

isAnimationPropFunction · 0.85
setAttributeMethod · 0.65
setPropertyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…