react / react/yoga

Incorrect object identity in JavaScript bindings

Open
#1,858 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18.9k
Forks
1.6k
Avg merge
1m
Merged PRs (30d)
1

Description

Summary

After calling parent.insertChild(child, 0), both child.getParent() === parent and parent.getChild(0) === child return false, even though the operation appears successful.

Environment

  • Package: yoga-layout@3.2.1
  • Runtime: Node.js v24.4.1, Bun v1.2.21
  • Platform: macOS arm64

Reproduction

import Yoga from 'yoga-layout';

const config = Yoga.Config.create();
const parent = Yoga.Node.createWithConfig(config);
const child = Yoga.Node.createWithConfig(config);

parent.insertChild(child, 0);

console.log('child.getParent() === parent:', child.getParent() === parent);   // false
console.log('parent.getChild(0) === child:', parent.getChild(0) === child);   // false
console.log('Parent child count:', parent.getChildCount());                   // 1

Expected Behavior

After insertChild():

  • child.getParent() === parent should return true
  • parent.getChild(0) === child should return true

Actual Behavior

  • child.getParent() === parent returns false
  • parent.getChild(0) === child returns false
  • parent.getChildCount() correctly returns 1
  • child.getParent() returns a truthy object but not the same reference

Impact

This breaks any code that relies on object identity for tree traversal or manipulation. Layout calculations work correctly, but tree structure algorithms fail.

Analysis

The WASM bindings appear to create new JavaScript wrapper objects for each getParent()/getChild() call instead of maintaining consistent object identity mapping.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the JavaScript reproduction through the WASM bindings, focusing on insertChild(), getParent(), and getChild(). Trace how those entry points return objects and verify that repeated lookups preserve the original JavaScript references; the issue is done when both identity comparisons return true while the child count remains 1.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, wasm
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.