( renderer: Renderer, isClassBased: boolean, rNode: RElement, prop: string, value: any, )
| 1133 | * otherwise). |
| 1134 | */ |
| 1135 | export function applyStyling( |
| 1136 | renderer: Renderer, |
| 1137 | isClassBased: boolean, |
| 1138 | rNode: RElement, |
| 1139 | prop: string, |
| 1140 | value: any, |
| 1141 | ) { |
| 1142 | if (isClassBased) { |
| 1143 | // We actually want JS true/false here because any truthy value should add the class |
| 1144 | if (!value) { |
| 1145 | renderer.removeClass(rNode, prop); |
| 1146 | } else { |
| 1147 | renderer.addClass(rNode, prop); |
| 1148 | } |
| 1149 | } else { |
| 1150 | let flags = prop.indexOf('-') === -1 ? undefined : (RendererStyleFlags2.DashCase as number); |
| 1151 | if (value == null /** || value === undefined */) { |
| 1152 | renderer.removeStyle(rNode, prop, flags); |
| 1153 | } else { |
| 1154 | // A value is important if it ends with `!important`. The style |
| 1155 | // parser strips any semicolons at the end of the value. |
| 1156 | const isImportant = typeof value === 'string' ? value.endsWith('!important') : false; |
| 1157 | |
| 1158 | if (isImportant) { |
| 1159 | // !important has to be stripped from the value for it to be valid. |
| 1160 | value = value.slice(0, -10); |
| 1161 | flags! |= RendererStyleFlags2.Important; |
| 1162 | } |
| 1163 | |
| 1164 | renderer.setStyle(rNode, prop, value, flags); |
| 1165 | } |
| 1166 | } |
| 1167 | } |
no test coverage detected