Incorrect object identity in JavaScript bindings
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() === parentshould returntrueparent.getChild(0) === childshould returntrue
Actual Behavior
child.getParent() === parentreturnsfalseparent.getChild(0) === childreturnsfalseparent.getChildCount()correctly returns1child.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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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