MCPcopy Create free account
hub / github.com/angular/angular / updateStyling

Function updateStyling

packages/core/src/render3/instructions/styling.ts:881–913  ·  view source on GitHub ↗

* Update a simple (property name) styling. * * This function takes `prop` and updates the DOM to that value. The function takes the binding * value as well as binding priority into consideration to determine which value should be written * to DOM. (For example it may be determined that there is

(
  tView: TView,
  tNode: TNode,
  lView: LView,
  renderer: Renderer,
  prop: string,
  value: string | undefined | null | boolean,
  isClassBased: boolean,
  bindingIndex: number,
)

Source from the content-addressed store, hash-verified

879 * @param bindingIndex Binding index of the binding.
880 */
881function updateStyling(
882 tView: TView,
883 tNode: TNode,
884 lView: LView,
885 renderer: Renderer,
886 prop: string,
887 value: string | undefined | null | boolean,
888 isClassBased: boolean,
889 bindingIndex: number,
890) {
891 if (!(tNode.type & TNodeType.AnyRNode)) {
892 // It is possible to have styling on non-elements (such as ng-container).
893 // This is rare, but it does happen. In such a case, just ignore the binding.
894 return;
895 }
896 const tData = tView.data;
897 const tRange = tData[bindingIndex + 1] as TStylingRange;
898 const higherPriorityValue = getTStylingRangeNextDuplicate(tRange)
899 ? findStylingValue(tData, tNode, lView, prop, getTStylingRangeNext(tRange), isClassBased)
900 : undefined;
901 if (!isStylingValuePresent(higherPriorityValue)) {
902 // We don't have a next duplicate, or we did not find a duplicate value.
903 if (!isStylingValuePresent(value)) {
904 // We should delete current value or restore to lower priority value.
905 if (getTStylingRangePrevDuplicate(tRange)) {
906 // We have a possible prev duplicate, let's retrieve it.
907 value = findStylingValue(tData, null, lView, prop, bindingIndex, isClassBased);
908 }
909 }
910 const rNode = getNativeByIndex(getSelectedIndex(), lView) as RElement;
911 applyStyling(renderer, isClassBased, rNode, prop, value);
912 }
913}
914
915/**
916 * Search for styling value with higher priority which is overwriting current value, or a

Callers 2

checkStylingPropertyFunction · 0.85
updateStylingMapFunction · 0.85

Calls 8

getTStylingRangeNextFunction · 0.90
getNativeByIndexFunction · 0.90
getSelectedIndexFunction · 0.90
applyStylingFunction · 0.90
findStylingValueFunction · 0.85
isStylingValuePresentFunction · 0.85

Tested by

no test coverage detected