medikoo / medikoo/dbjs

Rethink automatic descriptor resolution

Open
#32 0 comments 0 reactions 1 assignee View on GitHub

@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.

  1. 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.
  2. Do not return base descriptor (of $ id), from getDescriptor call, so it's accessible via public API.
  3. Freeze base descriptor (of $ id) (via Object.freeze) so any changes on it are forbidden.

Contributor guide

No contributing guide indexed for this repository

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.