Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native Class Inheritance Issue #10915

Closed
cbratschi opened this issue Jan 20, 2017 · 1 comment
Closed

Native Class Inheritance Issue #10915

cbratschi opened this issue Jan 20, 2017 · 1 comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. v8 engine Issues and PRs related to the V8 dependency.

Comments

@cbratschi
Copy link

cbratschi commented Jan 20, 2017

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

@addaleax addaleax added duplicate Issues and PRs that are duplicates of other issues or PRs. v8 engine Issues and PRs related to the V8 dependency. labels Jan 20, 2017
@addaleax
Copy link
Member

This seems to be a duplicate of #9288. You can subscribe to that thread and #9293 (the PR that would fix this in v6.x, if it works at some point) to stay up to date.

I’m closing this as a duplicate but feel free to ask follow-up questions if there are any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

2 participants