( renderer: Renderer, isClassBased: boolean, rNode: RElement, prop: string, value: any, )
| 1108 | * otherwise). |
| 1109 | */ |
| 1110 | export function applyStyling( |
| 1111 | renderer: Renderer, |
| 1112 | isClassBased: boolean, |
| 1113 | rNode: RElement, |
| 1114 | prop: string, |
| 1115 | value: any, |
| 1116 | ) { |
| 1117 | if (isClassBased) { |
| 1118 | // We actually want JS true/false here because any truthy value should add the class |
| 1119 | if (!value) { |
| 1120 | renderer.removeClass(rNode, prop); |
| 1121 | } else { |
| 1122 | renderer.addClass(rNode, prop); |
| 1123 | } |
| 1124 | } else { |
| 1125 | let flags = prop.indexOf('-') === -1 ? undefined : (RendererStyleFlags2.DashCase as number); |
| 1126 | if (value == null /** || value === undefined */) { |
| 1127 | renderer.removeStyle(rNode, prop, flags); |
| 1128 | } else { |
| 1129 | // A value is important if it ends with `!important`. The style |
| 1130 | // parser strips any semicolons at the end of the value. |
| 1131 | const isImportant = typeof value === 'string' ? value.endsWith('!important') : false; |
| 1132 | |
| 1133 | if (isImportant) { |
| 1134 | // !important has to be stripped from the value for it to be valid. |
| 1135 | value = value.slice(0, -10); |
| 1136 | flags! |= RendererStyleFlags2.Important; |
| 1137 | } |
| 1138 | |
| 1139 | renderer.setStyle(rNode, prop, value, flags); |
| 1140 | } |
| 1141 | } |
| 1142 | } |
no test coverage detected