MCPcopy
hub / github.com/angular/angular / setElementAttribute

Function setElementAttribute

packages/core/src/render3/instructions/shared.ts:521–542  ·  view source on GitHub ↗
(
  renderer: Renderer,
  element: RElement,
  namespace: string | null | undefined,
  tagName: string | null,
  name: string,
  value: any,
  sanitizer: SanitizerFn | null | undefined,
)

Source from the content-addressed store, hash-verified

519}
520
521export function setElementAttribute(
522 renderer: Renderer,
523 element: RElement,
524 namespace: string | null | undefined,
525 tagName: string | null,
526 name: string,
527 value: any,
528 sanitizer: SanitizerFn | null | undefined,
529) {
530 if (value == null) {
531 if (sanitizer != null) {
532 // Execute sanitizer to enforce security controls (e.g., neutralizing iframe)
533 sanitizer(value, tagName || '', name);
534 }
535 renderer.removeAttribute(element, name, namespace);
536 } else {
537 const strValue =
538 sanitizer == null ? renderStringify(value) : sanitizer(value, tagName || '', name);
539
540 renderer.setAttribute(element, name, strValue as string, namespace);
541 }
542}
543
544/**
545 * Sets initial input properties on directive instances from attribute data

Callers 4

applyMutableOpCodesFunction · 0.90
applyUpdateOpCodesFunction · 0.90
ɵɵariaPropertyFunction · 0.90
elementAttributeInternalFunction · 0.85

Calls 3

renderStringifyFunction · 0.90
removeAttributeMethod · 0.65
setAttributeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…