Skip to content

Incorrect object identity in JavaScript bindings #1858

@brainkim

Description

@brainkim

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions