-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
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: [email protected]
- 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()); // 1Expected 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.
Metadata
Metadata
Assignees
Labels
No labels