MCPcopy Create free account
hub / github.com/angular/angular / setElementAttribute

Function setElementAttribute

packages/core/src/render3/dom_node_manipulation.ts:111–132  ·  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

109 */
110
111export function setElementAttribute(
112 renderer: Renderer,
113 element: RElement,
114 namespace: string | null | undefined,
115 tagName: string | null,
116 name: string,
117 value: any,
118 sanitizer: SanitizerFn | null | undefined,
119) {
120 if (value == null) {
121 if (sanitizer != null) {
122 // Execute sanitizer to enforce security controls (e.g., neutralizing iframe)
123 sanitizer(value, tagName || '', name);
124 }
125 renderer.removeAttribute(element, name, namespace);
126 } else {
127 const strValue =
128 sanitizer == null ? renderStringify(value) : sanitizer(value, tagName || '', name);
129
130 renderer.setAttribute(element, name, strValue as string, namespace);
131 }
132}
133
134/**
135 * Write `cssText` to `RElement`.

Callers 4

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

Calls 3

renderStringifyFunction · 0.90
removeAttributeMethod · 0.65
setAttributeMethod · 0.65

Tested by

no test coverage detected