Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($parse): move global getter out of parse.js
Browse files Browse the repository at this point in the history
  • Loading branch information
chirayuk authored and btford committed Aug 12, 2013
1 parent cbe31d8 commit 099138f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
27 changes: 27 additions & 0 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -1104,3 +1104,30 @@ function assertArgFn(arg, name, acceptArrayAnnotation) {
(arg && typeof arg == 'object' ? arg.constructor.name || 'Object' : typeof arg));
return arg;
}

/**
* Return the value accessible from the object by path. Any undefined traversals are ignored
* @param {Object} obj starting object
* @param {string} path path to traverse
* @param {boolean=true} bindFnToScope
* @returns value as accessible by path
*/
//TODO(misko): this function needs to be removed
function getter(obj, path, bindFnToScope) {
if (!path) return obj;
var keys = path.split('.');
var key;
var lastInstance = obj;
var len = keys.length;

for (var i = 0; i < len; i++) {
key = keys[i];
if (obj) {
obj = (lastInstance = obj)[key];
}
}
if (!bindFnToScope && isFunction(obj)) {
return bind(lastInstance, obj);
}
return obj;
}
27 changes: 0 additions & 27 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,33 +663,6 @@ function setter(obj, path, setValue) {
return setValue;
}

/**
* Return the value accesible from the object by path. Any undefined traversals are ignored
* @param {Object} obj starting object
* @param {string} path path to traverse
* @param {boolean=true} bindFnToScope
* @returns value as accesbile by path
*/
//TODO(misko): this function needs to be removed
function getter(obj, path, bindFnToScope) {
if (!path) return obj;
var keys = path.split('.');
var key;
var lastInstance = obj;
var len = keys.length;

for (var i = 0; i < len; i++) {
key = keys[i];
if (obj) {
obj = (lastInstance = obj)[key];
}
}
if (!bindFnToScope && isFunction(obj)) {
return bind(lastInstance, obj);
}
return obj;
}

var getterFnCache = {};

/**
Expand Down

0 comments on commit 099138f

Please sign in to comment.