Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Display "..." on getters to defer their evaluation #390

@ddsol

Description

@ddsol

In Bridge.js there's an access to val.__proto__[name], which seems like it should be okay. However, it is possible to define a getter that expects a complete instance, rather than a empty prototype.

For instance:

var proto = {
  get upperName() { return this.name.toUpperCase()}
};

var instance = Object.create(proto);
instance.name = 'Foo';
console.log(instance.upperName); //=> FOO

console.log(instance.__proto__.upperName); //Throws: Cannot read property 'toUpperCase' of undefined

Bridge.js could

  • Fetch the property get result from the original instance and put the value on the result upon an exception.
  • defineProperty any getters on the __proto__ so they continue to refer to the same instance. Any readout could then throw (i.e. result.__proto__.upperName still throws), but referring tto result[name] would not throw.
  • Fetch the property get result from the original instance and put the value on the __proto__ instead upon an exception.
  • Just show an error as the property value.

It seems to me the value should show somewhere, rather than an error displayed. In any case, as it stands now, it breaks the extension. The error can only be found in the console.

Also, property getters could throw for reasons other than an instance/proto issue. It's probably a good idea to catch errors thrown and display the error in the UI, rather than aborting the code flow of the extension. It could be as simple as storing the error as a string on the property or just calling dehydrate(err) on the caught error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions