MCPcopy Index your code
hub / github.com/immutable-js/immutable-js / normalizeElement

Function normalizeElement

website/src/worker/normalizeResult.ts:68–94  ·  view source on GitHub ↗
(
  immutableFormaters: Array<DevToolsFormatter>,
  item: Element | JsonMLElementList
)

Source from the content-addressed store, hash-verified

66}
67
68function normalizeElement(
69 immutableFormaters: Array<DevToolsFormatter>,
70 item: Element | JsonMLElementList
71): Element | JsonMLElementList {
72 if (!Array.isArray(item)) {
73 return item;
74 }
75
76 if (!isElement(item)) {
77 return item;
78 }
79
80 const explodedItem = explodeElement(item);
81
82 const { tagName, attributes, children } = explodedItem;
83
84 const normalizedChildren = children.map((child) =>
85 normalizeResult(immutableFormaters, child)
86 );
87
88 if (attributes) {
89 // @ts-expect-error type is not perfect here because of self-reference
90 return [tagName, attributes, ...normalizedChildren];
91 }
92
93 return [tagName, ...normalizedChildren];
94}

Callers 1

normalizeResultFunction · 0.85

Calls 4

isElementFunction · 0.90
explodeElementFunction · 0.90
normalizeResultFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected