forked from ember-cli/core-object
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hack to make this._super.someMethod available
- Loading branch information
Showing
1 changed file
with
4 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
function giveMethodSuper(target, fn) { | ||
function giveMethodSuper(name, target, fn) { | ||
return function() { | ||
var previous = this._super; | ||
this._super = target; | ||
this._super[name] = target; | ||
var ret = fn.apply(this, arguments); | ||
this._super = previous; | ||
return ret; | ||
|
@@ -36,9 +37,9 @@ function assignProperties(target, options) { | |
if (typeof value === 'function' && | ||
hasSuper(value)) { | ||
if (typeof target[key] === 'function') { | ||
target[key] = giveMethodSuper(target[key], value); | ||
target[key] = giveMethodSuper(key, target[key], value); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jgwhite
Author
Owner
|
||
} else { | ||
target[key] = giveMethodSuper(function() { }, value); | ||
target[key] = giveMethodSuper(key, function() { }, value); | ||
} | ||
} else { | ||
target[key] = value; | ||
|
It might be better to rename
target
tocontext
and do:You then put the lookup in
giveMethodSuper
. You'll still need to pivot off oftarget[key]
, but this feels more like a.apply
or.call
call on a function and is a little more clear on why you have to pass it. Just a thought.