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

Commit 099138f

Browse files
chirayukbtford
authored andcommitted
fix($parse): move global getter out of parse.js
1 parent cbe31d8 commit 099138f

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/Angular.js

+27
Original file line numberDiff line numberDiff line change
@@ -1104,3 +1104,30 @@ function assertArgFn(arg, name, acceptArrayAnnotation) {
11041104
(arg && typeof arg == 'object' ? arg.constructor.name || 'Object' : typeof arg));
11051105
return arg;
11061106
}
1107+
1108+
/**
1109+
* Return the value accessible from the object by path. Any undefined traversals are ignored
1110+
* @param {Object} obj starting object
1111+
* @param {string} path path to traverse
1112+
* @param {boolean=true} bindFnToScope
1113+
* @returns value as accessible by path
1114+
*/
1115+
//TODO(misko): this function needs to be removed
1116+
function getter(obj, path, bindFnToScope) {
1117+
if (!path) return obj;
1118+
var keys = path.split('.');
1119+
var key;
1120+
var lastInstance = obj;
1121+
var len = keys.length;
1122+
1123+
for (var i = 0; i < len; i++) {
1124+
key = keys[i];
1125+
if (obj) {
1126+
obj = (lastInstance = obj)[key];
1127+
}
1128+
}
1129+
if (!bindFnToScope && isFunction(obj)) {
1130+
return bind(lastInstance, obj);
1131+
}
1132+
return obj;
1133+
}

src/ng/parse.js

-27
Original file line numberDiff line numberDiff line change
@@ -663,33 +663,6 @@ function setter(obj, path, setValue) {
663663
return setValue;
664664
}
665665

666-
/**
667-
* Return the value accesible from the object by path. Any undefined traversals are ignored
668-
* @param {Object} obj starting object
669-
* @param {string} path path to traverse
670-
* @param {boolean=true} bindFnToScope
671-
* @returns value as accesbile by path
672-
*/
673-
//TODO(misko): this function needs to be removed
674-
function getter(obj, path, bindFnToScope) {
675-
if (!path) return obj;
676-
var keys = path.split('.');
677-
var key;
678-
var lastInstance = obj;
679-
var len = keys.length;
680-
681-
for (var i = 0; i < len; i++) {
682-
key = keys[i];
683-
if (obj) {
684-
obj = (lastInstance = obj)[key];
685-
}
686-
}
687-
if (!bindFnToScope && isFunction(obj)) {
688-
return bind(lastInstance, obj);
689-
}
690-
return obj;
691-
}
692-
693666
var getterFnCache = {};
694667

695668
/**

0 commit comments

Comments
 (0)