( tNode: TNode, lView: LView, propName: string, value: T, renderer: Renderer, sanitizer: SanitizerFn | null | undefined, )
| 283 | * @param sanitizer Function used to sanitize the value before setting it. |
| 284 | */ |
| 285 | export function setDomProperty<T>( |
| 286 | tNode: TNode, |
| 287 | lView: LView, |
| 288 | propName: string, |
| 289 | value: T, |
| 290 | renderer: Renderer, |
| 291 | sanitizer: SanitizerFn | null | undefined, |
| 292 | ) { |
| 293 | if (tNode.type & TNodeType.AnyRNode) { |
| 294 | const element = getNativeByTNode(tNode, lView) as RElement | RComment; |
| 295 | |
| 296 | if (ngDevMode) { |
| 297 | if (lView[TVIEW].firstUpdatePass) { |
| 298 | validateAgainstEventProperties(propName); |
| 299 | } |
| 300 | if (!isPropertyValid(element, propName, tNode.value, lView[TVIEW].schemas)) { |
| 301 | handleUnknownPropertyError(propName, tNode.value, tNode.type, lView); |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | // It is assumed that the sanitizer is only added when the compiler determines that the |
| 306 | // property is risky, so sanitization can be done without further checks. |
| 307 | value = sanitizer != null ? (sanitizer(value, tNode.value || '', propName) as any) : value; |
| 308 | renderer.setProperty(element as RElement, propName, value); |
| 309 | } else if (tNode.type & TNodeType.AnyContainer) { |
| 310 | // If the node is a container and the property didn't |
| 311 | // match any of the inputs or schemas we should throw. |
| 312 | if (ngDevMode && !matchingSchemas(lView[TVIEW].schemas, tNode.value)) { |
| 313 | handleUnknownPropertyError(propName, tNode.value, tNode.type, lView); |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | /** If node is an OnPush component, marks its LView dirty. */ |
| 319 | export function markDirtyIfOnPush(lView: LView, viewIndex: number): void { |
no test coverage detected
searching dependent graphs…