You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and returned it from a function. When the function was called from javascript, the returned value of the function was destructed like (snippet from here)
validity={...validity, ...customValidity};
where customValidity is the said returned value, the values of struct's fields were assigned on prototype as getters and setters and were not enumerable. Since destructuring only reads the enumerable proprety keys, those values were not available on the final object, validity in this case.
Proposed Solution
Have a attribute that marks a property as enumerable like such
Motivation
I recently ran into this issue where I exported a struct like (original sturct that was used)
and returned it from a function. When the function was called from javascript, the returned value of the function was destructed like (snippet from here)
where
customValidity
is the said returned value, the values of struct's fields were assigned on prototype as getters and setters and were not enumerable. Since destructuring only reads the enumerable proprety keys, those values were not available on the final object,validity
in this case.Proposed Solution
Have a attribute that marks a property as enumerable like such
This value will then be set as an enumerable property on the resulting javascript object
Alternatives
Use getters and setters to assign the properties on the object manually but obviously this adds a lot of boilerplate.
Additional Context
console.log
of returned value from function:Object.keys
of returned value:After destruction:
`
I hope I made the issue clear. Let me know if any clarification is needed.
The text was updated successfully, but these errors were encountered: