Rethink automatic descriptor resolution
@medikoo is already working on this.
Since May 20, 2015.
- Dominant language
- JavaScript
- Stars
- 27
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
/cc @kamsi
Currently when doing obj.getDescriptor('x') we'll always get some descriptor. If property was never defined, we'll get base descriptor that is ancestor for each descriptor in a database (a base descriptor prototype)
It's dangerous, as when we try to do obj.getDescriptor('x').someSetting = value we may accidentally set this value for every property in a system.
Currently as an alternative there's obj.getOwnDescriptor('x') which by all means will return descriptor for given object (if it didn't exist, it's created and returned). Still it's dirty, as it creates objects we may not need. It's also usually not used, as in most cases we call getDescriptor on instances to get descriptor of prototype properties.
I see three possible solutions at the moment.
- Make
getOwnDescriptor(or create alternative method) so it returns own descriptor only if it exists, and returns null otherwise. It will quickly expose eventual bugs. - Do not return base descriptor (of
$id), fromgetDescriptorcall, so it's accessible via public API. - Freeze base descriptor (of
$id) (viaObject.freeze) so any changes on it are forbidden.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.