From d2a7d5838e949843b6a45c59bfea124b4f1a1678 Mon Sep 17 00:00:00 2001 From: Karl Seamon Date: Mon, 2 Dec 2013 18:20:50 -0500 Subject: [PATCH 1/3] Applies a bit of micro-optimization to ensureSafeObject. --- src/ng/parse.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/ng/parse.js b/src/ng/parse.js index 3be985739243..6aa42d905d5d 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.nodeType) { + throw $parseMinErr('isecdom', + 'Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}', + fullExpression); + } } + return obj; } var OPERATORS = { From 69e2bed1bae28a95b159a71186d35be212f9bb3b Mon Sep 17 00:00:00 2001 From: Karl Seamon Date: Tue, 3 Dec 2013 13:37:47 -0500 Subject: [PATCH 2/3] Fixes the not-workiness. --- src/ng/parse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/parse.js b/src/ng/parse.js index 6aa42d905d5d..89bbab14d216 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -55,7 +55,7 @@ function ensureSafeObject(obj, fullExpression) { 'Referencing the Window in Angular expressions is disallowed! Expression: {0}', fullExpression); } else if (// isElement(obj) - obj.nodeType) { + (obj.children && (obj.nodeName || (obj.on && obj.find)))) { throw $parseMinErr('isecdom', 'Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}', fullExpression); From a72e9ed3ad7a07765ce0bb7e1ba818e4290b36d2 Mon Sep 17 00:00:00 2001 From: Karl Seamon Date: Tue, 3 Dec 2013 13:55:08 -0500 Subject: [PATCH 3/3] removed () --- src/ng/parse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/parse.js b/src/ng/parse.js index 89bbab14d216..8b3f145a8211 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -55,7 +55,7 @@ function ensureSafeObject(obj, fullExpression) { 'Referencing the Window in Angular expressions is disallowed! Expression: {0}', fullExpression); } else if (// isElement(obj) - (obj.children && (obj.nodeName || (obj.on && obj.find)))) { + obj.children && (obj.nodeName || (obj.on && obj.find))) { throw $parseMinErr('isecdom', 'Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}', fullExpression);