-
-
Notifications
You must be signed in to change notification settings - Fork 619
Expand file tree
/
Copy pathmeasureUtil.ts
More file actions
31 lines (29 loc) · 879 Bytes
/
measureUtil.ts
File metadata and controls
31 lines (29 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Attributes that should be removed from measure row DOM to avoid conflicts
*/
const FILTERED_ATTRIBUTES = [
// Unique identifiers that shouldn't be duplicated in DOM
'id',
'data-testid',
'data-test-id',
'data-cy', // Cypress
'data-qa',
'data-automation-id',
'data-id',
'data-key',
] as const;
/**
* Remove all ID and test attributes from DOM element and its descendants
* This ensures the measure row complies with HTML spec (no duplicate IDs)
* and works with custom components whose internal DOM we cannot control at React level
* @param element - The DOM element to clean
*/
export function cleanMeasureRowAttributes(element: HTMLElement): void {
if (!element) return;
const allElements = element.querySelectorAll('*');
allElements.forEach(el => {
FILTERED_ATTRIBUTES.forEach(attr => {
el.removeAttribute(attr);
});
});
}