Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

convert to more efficient and straight forward context passing

Enyo-DCO-1.1-Signed-off-by: Cole Davis <cole.davis@lge.com>
  • Loading branch information...
commit c70577ba385ed6edb0660dd02d388026781e8a73 1 parent 65beb1c
@clinuz clinuz authored
Showing with 4 additions and 8 deletions.
  1. +1 −5 source/kernel/Object.js
  2. +3 −3 source/kernel/lang.js
View
6 source/kernel/Object.js
@@ -110,12 +110,8 @@ enyo.kind({
// if there isn't a property do nothing
if (!enyo.exists(property)) return;
var fn = this[property + "FindAndInstance"];
- // if we have a callback bind it to the given object so that
- // it will be called under the correct context, if it has
- // already been bound this is harmless
- fn = enyo.exists(fn) && "function" === typeof fn? enyo.bind(this, fn): null;
// go ahead and call the enyo scoped version of this method
- return enyo.findAndInstance.call(this, property, fn);
+ return enyo.findAndInstance.call(this, property, fn, this);
},
//*@public
View
6 source/kernel/lang.js
@@ -248,7 +248,7 @@
was found and the second being the instance if it could be
determined.
*/
- enyo.findAndInstance = function (property, fn) {
+ enyo.findAndInstance = function (property, fn, context) {
var ctor;
var inst;
var path;
@@ -258,7 +258,7 @@
path = enyo.getPath.call(this, property);
// if there is nothing at the given property fast-path out
// and return undefined everything
- if (!path) return fn();
+ if (!path) return fn.call(context || this);
// if the path is a string (as in most cases) go ahead and
// attempt to get the kind definition or instance at the
// given path
@@ -287,7 +287,7 @@
// if we do have an instance assign it to the base object
if (exists(inst)) this[property] = inst;
// now use the calback and pass it the correct parameters
- return fn(ctor, inst);
+ return fn.call(context || this, ctor, inst);
};
//*@public
Please sign in to comment.
Something went wrong with that request. Please try again.