aframevr / aframevr/aframe

allow updating array/object-based prop type using same array/object

Open
#2,922 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
17.6k
Forks
4.4k
PR merge metrics
No merged PRs in 30d

Description

Description:

I'd like to be able to update an array property type using the same array without having the clone the object myself to get past the component deepEqual check.

// test component
schema: {
  foo: {type: 'array'}
}
var foo = el.getAttribute('test').foo;
foo.push(50);
el.setAttribute('test', 'foo', foo);

Currently I need to do:

var foo = el.getAttribute('test').foo;
foo.push(50);
el.setAttribute('test', 'foo', AFRAME.utils.clone(foo));

Possible solutions:

// Skip equals check flag or force update flag.
el.setAttribute('test', 'foo', foo, true)
// Options object for setAttribute
el.setAttribute('test', {foo: foo}, {forceUpdate: true, clobber: false});
  • Clone the object/array when setting oldData, but this doesn't sound great for perf.

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 at the component setAttribute path and the deepEqual check described in the issue. Trace how array and object prop values are compared and how old values are stored, then determine how a same-reference update should be recognized without changing unrelated setAttribute behavior. Done means the example updates foo after push without requiring AFRAME.utils.clone(foo), with coverage for array and object props.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
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.