MCPcopy Create free account
hub / github.com/donghaxkim/react-rewrite / flattenRangeIntoText

Function flattenRangeIntoText

packages/cli/src/transform.ts:1180–1189  ·  view source on GitHub ↗
(parentNode: any, firstChildIndex: number, lastChildIndex: number, replacementText: string)

Source from the content-addressed store, hash-verified

1178}
1179
1180function flattenRangeIntoText(parentNode: any, firstChildIndex: number, lastChildIndex: number, replacementText: string): boolean {
1181 const children = parentNode.children;
1182 if (!children) return false;
1183 if (replacementText === "") {
1184 children.splice(firstChildIndex, lastChildIndex - firstChildIndex + 1);
1185 return true;
1186 }
1187 children.splice(firstChildIndex, lastChildIndex - firstChildIndex + 1, { type: "JSXText", value: replacementText });
1188 return true;
1189}
1190
1191function createInsertionNode(text: string): any {
1192 if (text === " ") return createSpaceExpressionNode();

Callers 1

replaceCrossElementTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected