( dst: TAttributes | null, src: TAttributes | null, )
| 110 | * @param src `TAttributes` which should be appended to `dst` |
| 111 | */ |
| 112 | export 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. |
no test coverage detected
searching dependent graphs…