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

Function applyStyling

packages/core/src/render3/node_manipulation.ts:1054–1086  ·  view source on GitHub ↗
(
  renderer: Renderer,
  isClassBased: boolean,
  rNode: RElement,
  prop: string,
  value: any,
)

Source from the content-addressed store, hash-verified

1052 * otherwise).
1053 */
1054export function applyStyling(
1055 renderer: Renderer,
1056 isClassBased: boolean,
1057 rNode: RElement,
1058 prop: string,
1059 value: any,
1060) {
1061 if (isClassBased) {
1062 // We actually want JS true/false here because any truthy value should add the class
1063 if (!value) {
1064 renderer.removeClass(rNode, prop);
1065 } else {
1066 renderer.addClass(rNode, prop);
1067 }
1068 } else {
1069 let flags = prop.indexOf('-') === -1 ? undefined : (RendererStyleFlags2.DashCase as number);
1070 if (value == null /** || value === undefined */) {
1071 renderer.removeStyle(rNode, prop, flags);
1072 } else {
1073 // A value is important if it ends with `!important`. The style
1074 // parser strips any semicolons at the end of the value.
1075 const isImportant = typeof value === 'string' ? value.endsWith('!important') : false;
1076
1077 if (isImportant) {
1078 // !important has to be stripped from the value for it to be valid.
1079 value = value.slice(0, -10);
1080 flags! |= RendererStyleFlags2.Important;
1081 }
1082
1083 renderer.setStyle(rNode, prop, value, flags);
1084 }
1085 }
1086}

Callers 1

updateStylingFunction · 0.90

Calls 5

indexOfMethod · 0.80
removeClassMethod · 0.65
addClassMethod · 0.65
removeStyleMethod · 0.65
setStyleMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…