Skip to content

Commit

Permalink
[bugfix] Fix proto return value for native classes
Browse files Browse the repository at this point in the history
Native classes end up calling the nearest class constructor, and with
the recent refactor those class constructors return their own prototype
instead of the class instance's. This breaks certain functions that
currently rely on the `proto` function return the prototype of the
instance itself. We're seeing failures in `@ember-decorators/data`
due to this bug.

This reverts to returning the protoype on the instance directly.
  • Loading branch information
pzuraq committed Apr 13, 2018
1 parent c58044b commit 47e6aee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/ember-runtime/lib/system/core_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ function makeCtor(base) {
Class.PrototypeMixin.applyPartial(Class.prototype);
}

return Class.prototype;
// Native classes will call the nearest superclass's proto function,
// and proto is expected to return the current instance's prototype,
// so we need to return it from `this` instead
return this.prototype;
};

return Class;
Expand Down

0 comments on commit 47e6aee

Please sign in to comment.