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

Commit cefdaf1

Browse files
committed
fix($parse): move global getter out of parse.js
1 parent 38deedd commit cefdaf1

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
@@ -1078,3 +1078,30 @@ function assertArgFn(arg, name, acceptArrayAnnotation) {
10781078
(arg && typeof arg == 'object' ? arg.constructor.name || 'Object' : typeof arg));
10791079
return arg;
10801080
}
1081+
1082+
/**
1083+
* Return the value accessible from the object by path. Any undefined traversals are ignored
1084+
* @param {Object} obj starting object
1085+
* @param {string} path path to traverse
1086+
* @param {boolean=true} bindFnToScope
1087+
* @returns value as accessible by path
1088+
*/
1089+
//TODO(misko): this function needs to be removed
1090+
function getter(obj, path, bindFnToScope) {
1091+
if (!path) return obj;
1092+
var keys = path.split('.');
1093+
var key;
1094+
var lastInstance = obj;
1095+
var len = keys.length;
1096+
1097+
for (var i = 0; i < len; i++) {
1098+
key = keys[i];
1099+
if (obj) {
1100+
obj = (lastInstance = obj)[key];
1101+
}
1102+
}
1103+
if (!bindFnToScope && isFunction(obj)) {
1104+
return bind(lastInstance, obj);
1105+
}
1106+
return obj;
1107+
}

src/ng/parse.js

-27
Original file line numberDiff line numberDiff line change
@@ -721,33 +721,6 @@ function setter(obj, path, setValue) {
721721
return setValue;
722722
}
723723

724-
/**
725-
* Return the value accessible from the object by path. Any undefined traversals are ignored
726-
* @param {Object} obj starting object
727-
* @param {string} path path to traverse
728-
* @param {boolean=true} bindFnToScope
729-
* @returns value as accessible by path
730-
*/
731-
//TODO(misko): this function needs to be removed
732-
function getter(obj, path, bindFnToScope) {
733-
if (!path) return obj;
734-
var keys = path.split('.');
735-
var key;
736-
var lastInstance = obj;
737-
var len = keys.length;
738-
739-
for (var i = 0; i < len; i++) {
740-
key = keys[i];
741-
if (obj) {
742-
obj = (lastInstance = obj)[key];
743-
}
744-
}
745-
if (!bindFnToScope && isFunction(obj)) {
746-
return bind(lastInstance, obj);
747-
}
748-
return obj;
749-
}
750-
751724
var getterFnCache = {};
752725

753726
/**

0 commit comments

Comments
 (0)