metafizzy / metafizzy/zdog

name option for items, so they can be accessed after copyGraph

Open
#6 3 comments 14 reactions 0 assignees View on GitHub
feature request
Dominant language
JavaScript
Stars
10.7k
Forks
407
PR merge metrics
No merged PRs in 30d

Description

**Add a 👍 reaction** to this issue if you would like to see this feature added. Do not add +1 comments — [They will be deleted](https://metafizzy.co/blog/use-github-reactions-delete-plus-1-comments/).

---

Right now there's no easy way to access a child of a parent copied with `copyGraph`.

``` js
// right arm
let upperArm = new Zdog.Shape({
//...
});
let foreArm = new Zdog.Shape({
addTo: upperArm,
// ...
});
// hand
new Zdog.Shape({
addTo: foreArm,
color: '#C25',
// ...
});

// left arm
upperArm.copyGraph();

// How do set the left hand to a different color?
```

With the `name` option, you could access children via an Object property.

``` js
// right arm
let upperArm = new Zdog.Shape({
//...
});
new Zdog.Shape({
addTo: upperArm,
name: 'foreArm', // accessible as parent.foreArm
// ...
});
// hand
new Zdog.Shape({
addTo: upperArm.foreArm,
name: 'hand', // accessible as parent.hand
color: '#C25',
// ...
});

// left arm
let leftArm = upperArm.copyGraph();

// set left hand to different color
leftArm.foreArm.hand.color = '#EA0';
```

Contributor guide

Open the contributing guide

Research direction

The issue identifies copyGraph as the entry point and shows the intended parent.foreArm and leftArm.foreArm.hand access pattern; start by tracing that API and its child-copy behavior. Done means named descendants remain accessible on the copied graph and the demonstrated hand-color change works, with coverage for this behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.