From 23c922997d71ca653bacf294460bea31be823f6b Mon Sep 17 00:00:00 2001 From: Daniel Herman Date: Wed, 10 Jun 2015 14:46:56 -0400 Subject: [PATCH] perf(ngSwitch): Define this directive as terminal Since a switch statement ( and therefore `ngSwitch` ) can really be thought of as simply a combination of if statements, there's no reason that this directive should differ from `ngIf` in how it compiles the element. This should also prevents needless compilation of directives when the ngSwitch condition isn't yet matched. --- src/ng/directive/ngSwitch.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ng/directive/ngSwitch.js b/src/ng/directive/ngSwitch.js index 79155f433af5..01ac1ec6979b 100644 --- a/src/ng/directive/ngSwitch.js +++ b/src/ng/directive/ngSwitch.js @@ -185,6 +185,7 @@ var ngSwitchDirective = ['$animate', function($animate) { var ngSwitchWhenDirective = ngDirective({ transclude: 'element', priority: 1200, + terminal: true, require: '^ngSwitch', multiElement: true, link: function(scope, element, attrs, ctrl, $transclude) { @@ -196,6 +197,7 @@ var ngSwitchWhenDirective = ngDirective({ var ngSwitchDefaultDirective = ngDirective({ transclude: 'element', priority: 1200, + terminal: true, require: '^ngSwitch', multiElement: true, link: function(scope, element, attr, ctrl, $transclude) {