mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-20 16:30:26 +00:00
fix($parse): move global getter out of parse.js
This commit is contained in:
parent
38deedd6e3
commit
cefdaf131d
2 changed files with 27 additions and 27 deletions
|
|
@ -1078,3 +1078,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -721,33 +721,6 @@ function setter(obj, path, setValue) {
|
|||
return setValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
var getterFnCache = {};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue