diff options
| author | Vojta Jina | 2012-04-14 10:39:24 -0700 | 
|---|---|---|
| committer | Vojta Jina | 2012-05-05 03:30:19 +0200 | 
| commit | 499a76a08cc7a7604dab5e1dd9cca675b8e29333 (patch) | |
| tree | 3b734d33f06ee87787c6245fb40ee005a7a81b86 /src/ng/parse.js | |
| parent | 8e2675029f5ca404a7c649cc161df3ea642d941f (diff) | |
| download | angular.js-499a76a08cc7a7604dab5e1dd9cca675b8e29333.tar.bz2 | |
fix($parse): support methods on falsy primitive types
e.g. zero, false, empty string
- fix tests to be executed with csp true
- fix cps (when more than 5 parts)
Diffstat (limited to 'src/ng/parse.js')
| -rw-r--r-- | src/ng/parse.js | 19 | 
1 files changed, 11 insertions, 8 deletions
| diff --git a/src/ng/parse.js b/src/ng/parse.js index a367c291..294e2c8d 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -695,7 +695,7 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4) {      var pathVal = (locals && locals.hasOwnProperty(key0)) ? locals : scope,          promise; -    if (!pathVal) return pathVal; +    if (pathVal === null || pathVal === undefined) return pathVal;      pathVal = pathVal[key0];      if (pathVal && pathVal.then) { @@ -706,7 +706,7 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4) {        }        pathVal = pathVal.$$v;      } -    if (!key1 || !pathVal) return pathVal; +    if (!key1 || pathVal === null || pathVal === undefined) return pathVal;      pathVal = pathVal[key1];      if (pathVal && pathVal.then) { @@ -717,7 +717,7 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4) {        }        pathVal = pathVal.$$v;      } -    if (!key2 || !pathVal) return pathVal; +    if (!key2 || pathVal === null || pathVal === undefined) return pathVal;      pathVal = pathVal[key2];      if (pathVal && pathVal.then) { @@ -728,7 +728,7 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4) {        }        pathVal = pathVal.$$v;      } -    if (!key3 || !pathVal) return pathVal; +    if (!key3 || pathVal === null || pathVal === undefined) return pathVal;      pathVal = pathVal[key3];      if (pathVal && pathVal.then) { @@ -739,7 +739,7 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4) {        }        pathVal = pathVal.$$v;      } -    if (!key4 || !pathVal) return pathVal; +    if (!key4 || pathVal === null || pathVal === undefined) return pathVal;      pathVal = pathVal[key4];      if (pathVal && pathVal.then) { @@ -767,18 +767,21 @@ function getterFn(path, csp) {      fn = (pathKeysLength < 6)          ? cspSafeGetterFn(pathKeys[0], pathKeys[1], pathKeys[2], pathKeys[3], pathKeys[4])          : function(scope, locals) { -          var i = 0, val; +          var i = 0, val            do {              val = cspSafeGetterFn(                      pathKeys[i++], pathKeys[i++], pathKeys[i++], pathKeys[i++], pathKeys[i++]                    )(scope, locals); +              locals = undefined; // clear after first iteration +            scope = val;            } while (i < pathKeysLength); -        }; +          return val; +        }    } else {      var code = 'var l, fn, p;\n';      forEach(pathKeys, function(key, index) { -      code += 'if(!s) return s;\n' + +      code += 'if(s === null || s === undefined) return s;\n' +                'l=s;\n' +                's='+ (index                        // we simply dereference 's' on any .dot notation | 
