Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions codeflash/languages/javascript/frameworks/react/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ def walk(node: Node) -> None:

def _contains_jsx(node: Node) -> bool:
"""Check if a tree-sitter node contains JSX elements."""
if node.type in ("jsx_element", "jsx_self_closing_element", "jsx_fragment"):
return True
return any(_contains_jsx(child) for child in node.children)
stack = [node]
while stack:
node = stack.pop()
if node.type in ("jsx_element", "jsx_self_closing_element", "jsx_fragment"):
return True
stack.extend(node.children)
return False


def _wrap_return_with_profiler(source: str, return_node: Node, profiler_id: str, safe_name: str) -> str:
Expand Down
Loading