-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single property schema where the property is an array does not work (broken since 1.0.0) #5242
Single property schema where the property is an array does not work (broken since 1.0.0) #5242
Comments
This seems indeed to be a long standing issue. I didn't know it worked before. I came across aframe-layers-component from 2020 that have a comment about the issue. |
Looks like it dates back to this change, which introduced all the code i have commented on & went into 0.9.0. I haven't been able to test with 0.9.0 because it didn't work at all - a WebXR issue.
But I presume it would be broken at 0.9.0. The unit test that I thought repro'd the problem doesn't actually work (it fails for other reasons). Also, this only seems to be broken when attributes are set prior to entity creation. E.g. However doing this in the console does exhibit the problem:
and you can then fix with this command:
I'll try to do an updated UT based on this repro. |
#5243 offers a fix for this, which seems to work - but there's a few things I don't understand well enough to have confidence in the fix. |
…haviour (#5500) * Added unit tests covering previously inconsistent component update behaviour * Unit tests for #5242 --------- Co-authored-by: Noeri Huisman <[email protected]> Co-authored-by: diarmidmackenzie <[email protected]>
Description:
Working version using A-Frame 0.8.0 here:
https://glitch.com/edit/#!/single-property-schema-array?path=index.html%3A8%3A23
Found when updating superframe emplate examples to 1.4.1.
Linked Glitch is a very simple example which uses a single property schema, where the property is an array, and outputs the data to screen via the 'text' property.
This works OK at 0.8.0. From 1.0.0, including at 1.4.1, this no longer works.
This branch adds a Unit Test that exhibits the problem, but I haven't figured out a good fix for this yet.
Diagnosis of the problem so far:
The component does not get classified as
isObjectBased
(I don't know for sure whether that's correct or not) because this expression is not true:here
Then, in
updateCachedAttrValue
,this.attrValue
gets set up correctly, but the array entries it points to have been copied in by reference, not value, and so get changed toundefined
on the call toclearObject
The relevant code is here
A puzzling earlier line of code is the use of
value instanceof Object
here, rather than usingisObject
.For an array,
isObject
is false, butvalue instanceof Object
is true, because an Array is an instance of an Object.The text was updated successfully, but these errors were encountered: