aboutsummaryrefslogtreecommitdiffstats
path: root/src/Scope.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/Scope.js')
-rw-r--r--src/Scope.js23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/Scope.js b/src/Scope.js
index 4d2aa5c3..27fafc3a 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -44,9 +44,10 @@ function setter(instance, path, value){
}
///////////////////////////////////
-
-var getterFnCache = {};
-var JS_KEYWORDS = {};
+var scopeId = 0;
+ getterFnCache = {},
+ compileCache = {},
+ JS_KEYWORDS = {};
foreach(
["abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default",
"delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto",
@@ -75,7 +76,7 @@ function getterFn(path){
code += ' type = angular.Global.typeOf(last);\n';
code += ' fn = (angular[type.charAt(0).toUpperCase() + type.substring(1)]||{})["' + name + '"];\n';
code += ' if (fn)\n';
- code += ' self = function(){ return fn.apply(last, [last].concat(slice.call(arguments, 0, arguments.length))); };\n';
+ code += ' self = function(){ return fn.apply(last, [last].concat(Array.prototype.slice.call(arguments, 0, arguments.length))); };\n';
code += ' }\n';
}
});
@@ -88,7 +89,6 @@ function getterFn(path){
///////////////////////////////////
-var compileCache = {};
function expressionCompile(exp){
if (typeof exp === 'function') return exp;
var fn = compileCache[exp];
@@ -108,7 +108,6 @@ function errorHandlerFor(element, error) {
elementError(element, NG_EXCEPTION, isDefined(error) ? toJson(error) : error);
}
-var scopeId = 0;
function createScope(parent, services, existing) {
function Parent(){}
function API(){}
@@ -130,7 +129,8 @@ function createScope(parent, services, existing) {
$set: bind(instance, setter, instance),
$eval: function $eval(exp) {
- if (exp === undefined) {
+ var type = typeof exp;
+ if (type == 'undefined') {
for ( var i = 0, iSize = evalLists.sorted.length; i < iSize; i++) {
for ( var queue = evalLists.sorted[i],
jSize = queue.length,
@@ -138,18 +138,19 @@ function createScope(parent, services, existing) {
instance.$tryEval(queue[j].fn, queue[j].handler);
}
}
- } else if (typeof exp === 'function'){
+ } else if (type === 'function') {
return exp.call(instance);
- } else {
+ } else if (type === 'string') {
return expressionCompile(exp).call(instance);
}
},
$tryEval: function (expression, exceptionHandler) {
+ var type = typeof expression;
try {
- if (typeof expression == 'function') {
+ if (type == 'function') {
return expression.call(instance);
- } else {
+ } else if (type == 'string'){
return expressionCompile(expression).call(instance);
}
} catch (e) {