( keyValueArraySet: (keyValueArray: KeyValueArray<any>, key: string, value: any) => void, stringParser: (styleKeyValueArray: KeyValueArray<any>, text: string) => void, value: any | NO_CHANGE, isClassBased: boolean, )
| 280 | * @param isClassBased `true` if `class` change (`false` if `style`) |
| 281 | */ |
| 282 | export function checkStylingMap( |
| 283 | keyValueArraySet: (keyValueArray: KeyValueArray<any>, key: string, value: any) => void, |
| 284 | stringParser: (styleKeyValueArray: KeyValueArray<any>, text: string) => void, |
| 285 | value: any | NO_CHANGE, |
| 286 | isClassBased: boolean, |
| 287 | ): void { |
| 288 | const tView = getTView(); |
| 289 | const bindingIndex = incrementBindingIndex(2); |
| 290 | if (tView.firstUpdatePass) { |
| 291 | stylingFirstUpdatePass(tView, null, bindingIndex, isClassBased); |
| 292 | } |
| 293 | const lView = getLView(); |
| 294 | if (value !== NO_CHANGE && bindingUpdated(lView, bindingIndex, value)) { |
| 295 | // `getSelectedIndex()` should be here (rather than in instruction) so that it is guarded by the |
| 296 | // if so as not to read unnecessarily. |
| 297 | const tNode = tView.data[getSelectedIndex()] as TNode; |
| 298 | if (hasStylingInputShadow(tNode, isClassBased) && !isInHostBindings(tView, bindingIndex)) { |
| 299 | if (ngDevMode) { |
| 300 | // verify that if we are shadowing then `TData` is appropriately marked so that we skip |
| 301 | // processing this binding in styling resolution. |
| 302 | const tStylingKey = tView.data[bindingIndex]; |
| 303 | assertEqual( |
| 304 | Array.isArray(tStylingKey) ? tStylingKey[1] : tStylingKey, |
| 305 | false, |
| 306 | "Styling linked list shadow input should be marked as 'false'", |
| 307 | ); |
| 308 | } |
| 309 | // VE does not concatenate the static portion like we are doing here. |
| 310 | // Instead VE just ignores the static completely if dynamic binding is present. |
| 311 | // Because of locality we have already set the static portion because we don't know if there |
| 312 | // is a dynamic portion until later. If we would ignore the static portion it would look like |
| 313 | // the binding has removed it. This would confuse `[ngStyle]`/`[ngClass]` to do the wrong |
| 314 | // thing as it would think that the static portion was removed. For this reason we |
| 315 | // concatenate it so that `[ngStyle]`/`[ngClass]` can continue to work on changed. |
| 316 | let staticPrefix = isClassBased ? tNode.classesWithoutHost : tNode.stylesWithoutHost; |
| 317 | ngDevMode && |
| 318 | isClassBased === false && |
| 319 | staticPrefix !== null && |
| 320 | assertEqual(staticPrefix.endsWith(';'), true, "Expecting static portion to end with ';'"); |
| 321 | if (staticPrefix !== null) { |
| 322 | // We want to make sure that falsy values of `value` become empty strings. |
| 323 | value = concatStringsWithSpace(staticPrefix, value ? value : ''); |
| 324 | } |
| 325 | // Given `<div [style] my-dir>` such that `my-dir` has `@Input('style')`. |
| 326 | // This takes over the `[style]` binding. (Same for `[class]`) |
| 327 | setDirectiveInputsWhichShadowsStyling(tView, tNode, lView, value, isClassBased); |
| 328 | } else { |
| 329 | updateStylingMap( |
| 330 | tView, |
| 331 | tNode, |
| 332 | lView, |
| 333 | lView[RENDERER], |
| 334 | lView[bindingIndex + 1], |
| 335 | (lView[bindingIndex + 1] = toStylingKeyValueArray(keyValueArraySet, stringParser, value)), |
| 336 | isClassBased, |
| 337 | bindingIndex, |
| 338 | ); |
| 339 | } |
no test coverage detected