( tNode: TNode, lView: LView, propName: string, value: T, renderer: Renderer, sanitizer: SanitizerFn | null | undefined, )
| 287 | * @param sanitizer Function used to sanitize the value before setting it. |
| 288 | */ |
| 289 | export function setDomProperty<T>( |
| 290 | tNode: TNode, |
| 291 | lView: LView, |
| 292 | propName: string, |
| 293 | value: T, |
| 294 | renderer: Renderer, |
| 295 | sanitizer: SanitizerFn | null | undefined, |
| 296 | ) { |
| 297 | if (tNode.type & TNodeType.AnyRNode) { |
| 298 | const element = getNativeByTNode(tNode, lView) as RElement | RComment; |
| 299 | |
| 300 | if (ngDevMode) { |
| 301 | if (lView[TVIEW].firstUpdatePass) { |
| 302 | validateAgainstEventProperties(propName); |
| 303 | } |
| 304 | if (!isPropertyValid(element, propName, tNode.value, lView[TVIEW].schemas)) { |
| 305 | handleUnknownPropertyError(propName, tNode.value, tNode.type, lView); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | // It is assumed that the sanitizer is only added when the compiler determines that the |
| 310 | // property is risky, so sanitization can be done without further checks. |
| 311 | value = sanitizer != null ? (sanitizer(value, tNode.value || '', propName) as any) : value; |
| 312 | |
| 313 | // The `src` property previously used a sanitizer which mapped `null`/`undefined` to `''`. |
| 314 | // Now that `img` and `video` `src` are no longer sanitized, we still need to map `null` and |
| 315 | // `undefined` to `''` to avoid stringifying them to `'null'` or `'undefined'` and causing |
| 316 | // broken network requests. |
| 317 | |
| 318 | // TODO(v23): Remove this workaround once we can introduce a breaking change |
| 319 | value = unwrapImgVideoSrcValue(propName, element as RElement, value); |
| 320 | |
| 321 | renderer.setProperty(element as RElement, propName, value); |
| 322 | } else if (tNode.type & TNodeType.AnyContainer) { |
| 323 | // If the node is a container and the property didn't |
| 324 | // match any of the inputs or schemas we should throw. |
| 325 | if (ngDevMode && !matchingSchemas(lView[TVIEW].schemas, tNode.value)) { |
| 326 | handleUnknownPropertyError(propName, tNode.value, tNode.type, lView); |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * This function allows us to workaround a breaking change introduced by #71095 |
no test coverage detected