aframevr / aframe

:a: Web framework for building virtual reality experiences.
https://aframe.io/
MIT License
16.69k stars 3.98k forks source link

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

Open ngokevin opened 7 years ago

ngokevin commented 7 years ago

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});
dmarcos commented 5 years ago

@ngokevin Anything we want to still do?

ngokevin commented 5 years ago

Issues still applies. I'd set an internal __dirty flag to arrays (possibly objects) and override Array methods to detect if they are changed. Would allow to skip deep equal checks.