MCPcopy
hub / github.com/resend/react-email / sanitizeElement

Function sanitizeElement

packages/editor/src/utils/paste-sanitizer.ts:97–120  ·  view source on GitHub ↗
(el: HTMLElement)

Source from the content-addressed store, hash-verified

95}
96
97function sanitizeElement(el: HTMLElement): void {
98 const tagName = el.tagName.toLowerCase();
99
100 const allowedForTag = PRESERVED_ATTRIBUTES[tagName] || [];
101 const allowedGlobal = PRESERVED_ATTRIBUTES['*'] || [];
102 const allowed = new Set([...allowedForTag, ...allowedGlobal]);
103
104 const attributesToRemove: string[] = [];
105
106 for (const attr of Array.from(el.attributes)) {
107 if (attr.name.startsWith('data-')) {
108 attributesToRemove.push(attr.name);
109 continue;
110 }
111
112 if (!allowed.has(attr.name)) {
113 attributesToRemove.push(attr.name);
114 }
115 }
116
117 for (const attr of attributesToRemove) {
118 el.removeAttribute(attr);
119 }
120}

Callers 1

sanitizeNodeFunction · 0.85

Calls 2

pushMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…