MCPcopy
hub / github.com/angular/angular / setDomProperty

Function setDomProperty

packages/core/src/render3/instructions/shared.ts:285–316  ·  view source on GitHub ↗
(
  tNode: TNode,
  lView: LView,
  propName: string,
  value: T,
  renderer: Renderer,
  sanitizer: SanitizerFn | null | undefined,
)

Source from the content-addressed store, hash-verified

283 * @param sanitizer Function used to sanitize the value before setting it.
284 */
285export 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. */
319export function markDirtyIfOnPush(lView: LView, viewIndex: number): void {

Callers 3

ɵɵdomPropertyFunction · 0.90
setPropertyAndInputsFunction · 0.85

Calls 6

getNativeByTNodeFunction · 0.90
isPropertyValidFunction · 0.90
matchingSchemasFunction · 0.90
setPropertyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…