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

Function mergeHostAttrs

packages/core/src/render3/util/attrs_utils.ts:112–144  ·  view source on GitHub ↗
(
  dst: TAttributes | null,
  src: TAttributes | null,
)

Source from the content-addressed store, hash-verified

110 * @param src `TAttributes` which should be appended to `dst`
111 */
112export function mergeHostAttrs(
113 dst: TAttributes | null,
114 src: TAttributes | null,
115): TAttributes | null {
116 if (src === null || src.length === 0) {
117 // do nothing
118 } else if (dst === null || dst.length === 0) {
119 // We have source, but dst is empty, just make a copy.
120 dst = src.slice();
121 } else {
122 let srcMarker: AttributeMarker = AttributeMarker.ImplicitAttributes;
123 for (let i = 0; i < src.length; i++) {
124 const item = src[i];
125 if (typeof item === 'number') {
126 srcMarker = item;
127 } else {
128 if (srcMarker === AttributeMarker.NamespaceURI) {
129 // Case where we need to consume `key1`, `key2`, `value` items.
130 } else if (
131 srcMarker === AttributeMarker.ImplicitAttributes ||
132 srcMarker === AttributeMarker.Styles
133 ) {
134 // Case where we have to consume `key1` and `value` only.
135 mergeHostAttribute(dst, srcMarker, item as string, null, src[++i] as string);
136 } else {
137 // Case where we have to consume `key1` only.
138 mergeHostAttribute(dst, srcMarker, item as string, null, null);
139 }
140 }
141 }
142 }
143 return dst;
144}
145
146/**
147 * Append `key`/`value` to existing `TAttributes` taking region marker and duplicates into account.

Callers 6

attr_util_spec.tsFile · 0.90
domOnlyFirstCreatePassFunction · 0.90
initializeDirectivesFunction · 0.90
templateCreateFunction · 0.90

Calls 1

mergeHostAttributeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…