From e88d6179c3a6a137e75fa09de906fc83c6515db2 Mon Sep 17 00:00:00 2001
From: Lucas Galfasó
Date: Sun, 3 Mar 2013 22:23:29 -0300
Subject: feat(ng:switch): Preserve the order of the elements not in the
ng-switch
Preserve the order of the elements that are not part of a case nor default in
a ng-switch directive
BREAKING CHANGE: elements not in the ng-switch were rendered after the
ng-switch elements. Now they are rendered in-place.
Ng-switch directives should be updated with non ng-switch elements
in render-order. e.g.
The following was previously rendered with
1 after "2":
To keep the old behaviour, say:
Closes #1074
---
test/ng/directive/ngSwitchSpec.js | 62 +++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
(limited to 'test')
diff --git a/test/ng/directive/ngSwitchSpec.js b/test/ng/directive/ngSwitchSpec.js
index b817386c..85240b19 100644
--- a/test/ng/directive/ngSwitchSpec.js
+++ b/test/ng/directive/ngSwitchSpec.js
@@ -95,6 +95,68 @@ describe('ngSwitch', function() {
}));
+ it('should always display the elements that do not match a switch',
+ inject(function($rootScope, $compile) {
+ element = $compile(
+ '' +
+ '- always
' +
+ '- one
' +
+ '- two
' +
+ '- other,
' +
+ '- other too
' +
+ '
')($rootScope);
+ $rootScope.$apply();
+ expect(element.text()).toEqual('always other, other too ');
+ $rootScope.select = 1;
+ $rootScope.$apply();
+ expect(element.text()).toEqual('always one ');
+ }));
+
+
+ it('should display the elements that do not have ngSwitchWhen nor ' +
+ 'ngSwitchDefault at the position specified in the template, when the ' +
+ 'first and last elements in the ngSwitch body do not have a ngSwitch* ' +
+ 'directive', inject(function($rootScope, $compile) {
+ element = $compile(
+ '' +
+ '- 1
' +
+ '- 2
' +
+ '- 3
' +
+ '- 4
' +
+ '- 5
' +
+ '- 6
' +
+ '- 7
' +
+ '- 8
' +
+ '
')($rootScope);
+ $rootScope.$apply();
+ expect(element.text()).toEqual('135678');
+ $rootScope.select = 1;
+ $rootScope.$apply();
+ expect(element.text()).toEqual('12368');
+ }));
+
+
+ it('should display the elements that do not have ngSwitchWhen nor ' +
+ 'ngSwitchDefault at the position specified in the template when the ' +
+ 'first and last elements in the ngSwitch have a ngSwitch* directive',
+ inject(function($rootScope, $compile) {
+ element = $compile(
+ '' +
+ '- 2
' +
+ '- 3
' +
+ '- 4
' +
+ '- 5
' +
+ '- 6
' +
+ '- 7
' +
+ '
')($rootScope);
+ $rootScope.$apply();
+ expect(element.text()).toEqual('3567');
+ $rootScope.select = 1;
+ $rootScope.$apply();
+ expect(element.text()).toEqual('236');
+ }));
+
+
it('should call change on switch', inject(function($rootScope, $compile) {
element = $compile(
'' +
--
cgit v1.2.3