Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
mixinMethod now installs ‘mixinSuper’ instead of ‘super’ as the spe…
Browse files Browse the repository at this point in the history
…cial implementation for servicing super-calls from mixin functions, avoiding problems when nested method calls try to invoke `super` … our one mixed-in method that cares (`bind`) now uses `mixinSuper` instead of base `super`
  • Loading branch information
Scott Miles committed Jan 21, 2014
1 parent 37eea00 commit b1a4e7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/declaration/prototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@
// closures.
// As of now, there is only one problematic method, so
// we just patch it manually.
// To avoid re-entrancy problems, the special super method
// installed is called `mixinSuper` and the mixin method
// must use this method instead of the default `super`.
this.mixinMethod(extended, prototype, api.instance.mdv, 'bind');
// return buffed-up prototype
return extended;
Expand All @@ -161,10 +164,8 @@
return prototype[name].apply(this, args);
};
extended[name] = function() {
this.super = $super;
var value = api[name].apply(this, arguments);
this.super = extended.super;
return value;
this.mixinSuper = $super;
return api[name].apply(this, arguments);
}
},
// ensure prototype[name] inherits from a prototype.prototype[name]
Expand Down
4 changes: 3 additions & 1 deletion src/instance/mdv.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
}
var property = this.propertyForAttribute(name);
if (!property) {
return this.super(arguments);
// TODO(sjmiles): this mixin method must use the special form
// of `super` installed by `mixinMethod` in declaration/prototype.js
return this.mixinSuper(arguments);
} else {
// clean out the closets
this.unbind(name);
Expand Down

0 comments on commit b1a4e7d

Please sign in to comment.