diff options
| author | Karl Seamon | 2013-12-02 18:20:50 -0500 | 
|---|---|---|
| committer | Igor Minar | 2013-12-03 11:10:48 -0800 | 
| commit | 689dfb167924a61aef444ce7587fb987d8080990 (patch) | |
| tree | a1099726ee71de420cdf339dd0422d79f3ac6139 /src/ng/parse.js | |
| parent | 1169b5445691e1495354d235a3badf05240e3904 (diff) | |
| download | angular.js-689dfb167924a61aef444ce7587fb987d8080990.tar.bz2 | |
chore($parse): micro-optimization for ensureSafeObject function
This version matches the "alternate 2.2" version here: http://jsperf.com/ensuresafeobject/2
alternate 2.3 is a bit faster and simpler, but would break backwards compatibility.
Closes #5246
Diffstat (limited to 'src/ng/parse.js')
| -rw-r--r-- | src/ng/parse.js | 33 | 
1 files changed, 17 insertions, 16 deletions
| diff --git a/src/ng/parse.js b/src/ng/parse.js index 3be98573..8b3f145a 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -44,23 +44,24 @@ function ensureSafeMemberName(name, fullExpression) {  function ensureSafeObject(obj, fullExpression) {    // nifty check if obj is Function that is fast and works across iframes and other contexts -  if (obj && obj.constructor === obj) { -    throw $parseMinErr('isecfn', -        'Referencing Function in Angular expressions is disallowed! Expression: {0}', -        fullExpression); -  } else if (// isWindow(obj) -      obj && obj.document && obj.location && obj.alert && obj.setInterval) { -    throw $parseMinErr('isecwindow', -        'Referencing the Window in Angular expressions is disallowed! Expression: {0}', -        fullExpression); -  } else if (// isElement(obj) -      obj && (obj.nodeName || (obj.on && obj.find))) { -    throw $parseMinErr('isecdom', -        'Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}', -        fullExpression); -  } else { -    return obj; +  if (obj) { +    if (obj.constructor === obj) { +      throw $parseMinErr('isecfn', +          'Referencing Function in Angular expressions is disallowed! Expression: {0}', +          fullExpression); +    } else if (// isWindow(obj) +        obj.document && obj.location && obj.alert && obj.setInterval) { +      throw $parseMinErr('isecwindow', +          'Referencing the Window in Angular expressions is disallowed! Expression: {0}', +          fullExpression); +    } else if (// isElement(obj) +        obj.children && (obj.nodeName || (obj.on && obj.find))) { +      throw $parseMinErr('isecdom', +          'Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}', +          fullExpression); +    }    } +  return obj;  }  var OPERATORS = { | 
