Skip to content

Native Class Inheritance Issue #10915

@cbratschi

Description

@cbratschi
  • Version: v6.9.1
  • Platform: macOS (Darwin)
  • Subsystem: v8

A native v8 class is extended on the JavaScript side and new methods are added. However, those methods cannot be called in the newly created instance: they are undefined. Something seems to be wrong with the prototype chain. It also fails if the older prototyping syntax is being used.

The issue is reproducible on Node.js v.6.9.1. Node v4.x and v7.0.0 are not affected.

Sample code:

https://github.com/cbratschi/aminogfx-gl/blob/master/demos/tests/js.js

/**
 * Extend AminoGfx Class.
 */
class Circle extends Polygon {
   constructor(amino) {
       super(amino);

       console.log('Circle: constructor');

       /*
        * Issues:
        *
        *   - Node v6.9.1
        *     - TypeError: this.setup is not a function
        *
        * Works fine:
        *
        *   - Node v4.x
        *   - Node v7.0.0
        */
       this.setup();
   }

   setup() {
       console.log('Circle.setup()');
   }
}

Polygon is the native class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues and PRs that are duplicates of other issues or PRs.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions