MCPcopy
hub / github.com/angular/angular / checkStylingMap

Function checkStylingMap

packages/core/src/render3/instructions/styling.ts:243–302  ·  view source on GitHub ↗
(
  keyValueArraySet: (keyValueArray: KeyValueArray<any>, key: string, value: any) => void,
  stringParser: (styleKeyValueArray: KeyValueArray<any>, text: string) => void,
  value: any | NO_CHANGE,
  isClassBased: boolean,
)

Source from the content-addressed store, hash-verified

241 * @param isClassBased `true` if `class` change (`false` if `style`)
242 */
243export function checkStylingMap(
244 keyValueArraySet: (keyValueArray: KeyValueArray<any>, key: string, value: any) => void,
245 stringParser: (styleKeyValueArray: KeyValueArray<any>, text: string) => void,
246 value: any | NO_CHANGE,
247 isClassBased: boolean,
248): void {
249 const tView = getTView();
250 const bindingIndex = incrementBindingIndex(2);
251 if (tView.firstUpdatePass) {
252 stylingFirstUpdatePass(tView, null, bindingIndex, isClassBased);
253 }
254 const lView = getLView();
255 if (value !== NO_CHANGE && bindingUpdated(lView, bindingIndex, value)) {
256 // `getSelectedIndex()` should be here (rather than in instruction) so that it is guarded by the
257 // if so as not to read unnecessarily.
258 const tNode = tView.data[getSelectedIndex()] as TNode;
259 if (hasStylingInputShadow(tNode, isClassBased) && !isInHostBindings(tView, bindingIndex)) {
260 if (ngDevMode) {
261 // verify that if we are shadowing then `TData` is appropriately marked so that we skip
262 // processing this binding in styling resolution.
263 const tStylingKey = tView.data[bindingIndex];
264 assertEqual(
265 Array.isArray(tStylingKey) ? tStylingKey[1] : tStylingKey,
266 false,
267 "Styling linked list shadow input should be marked as 'false'",
268 );
269 }
270 // VE does not concatenate the static portion like we are doing here.
271 // Instead VE just ignores the static completely if dynamic binding is present.
272 // Because of locality we have already set the static portion because we don't know if there
273 // is a dynamic portion until later. If we would ignore the static portion it would look like
274 // the binding has removed it. This would confuse `[ngStyle]`/`[ngClass]` to do the wrong
275 // thing as it would think that the static portion was removed. For this reason we
276 // concatenate it so that `[ngStyle]`/`[ngClass]` can continue to work on changed.
277 let staticPrefix = isClassBased ? tNode.classesWithoutHost : tNode.stylesWithoutHost;
278 ngDevMode &&
279 isClassBased === false &&
280 staticPrefix !== null &&
281 assertEqual(staticPrefix.endsWith(';'), true, "Expecting static portion to end with ';'");
282 if (staticPrefix !== null) {
283 // We want to make sure that falsy values of `value` become empty strings.
284 value = concatStringsWithSpace(staticPrefix, value ? value : '');
285 }
286 // Given `<div [style] my-dir>` such that `my-dir` has `@Input('style')`.
287 // This takes over the `[style]` binding. (Same for `[class]`)
288 setDirectiveInputsWhichShadowsStyling(tView, tNode, lView, value, isClassBased);
289 } else {
290 updateStylingMap(
291 tView,
292 tNode,
293 lView,
294 lView[RENDERER],
295 lView[bindingIndex + 1],
296 (lView[bindingIndex + 1] = toStylingKeyValueArray(keyValueArraySet, stringParser, value)),
297 isClassBased,
298 bindingIndex,
299 );
300 }

Callers 2

ɵɵstyleMapFunction · 0.85
ɵɵclassMapFunction · 0.85

Calls 14

getTViewFunction · 0.90
incrementBindingIndexFunction · 0.90
getLViewFunction · 0.90
bindingUpdatedFunction · 0.90
getSelectedIndexFunction · 0.90
assertEqualFunction · 0.90
concatStringsWithSpaceFunction · 0.90
stylingFirstUpdatePassFunction · 0.85
hasStylingInputShadowFunction · 0.85
isInHostBindingsFunction · 0.85
updateStylingMapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…