-
Notifications
You must be signed in to change notification settings - Fork 27.5k
ngSwitch regression 1.2.14 and up - crash in ng-switch with multiple ng-switch-when using the same term. #7372
Comments
This does look like a regression, I'll see if I can put together a patch tomorrow morning if noone beats me to it |
Actually, you know what? I'm not sure the way it's being used in that plunkr was ever really supported. So maybe we shouldn't consider this a regression. Yeah, I'm not sure about this. |
hmm.. but we do have an array of $transclude functions for each case label, so I guess this is supported... yeah, it's a regression, okay... weird that we don't have tests for it! |
Thanks for the quick follow-up! |
… transclude fns Due to a regression introduced several releases ago, the ability for multiple transclude functions to work correctly changed, as they would break if different case labels had different numbers of transclude functions. This CL corrects this by not assuming that previous elements and scope count have the same length. Closes angular#7372
If come around this issue when using ng-switch within a form and a XHTML-page. It concerns 1.2.14 and greater and 1.3.beta7 (same error message) The error being thrown in Chrome looks like this (Version 34.0.1847.131 m): Error: previousElements[i] is undefined
|
Wait, this was added to v1.2.x also... So yeah, you're using old versions, @tmundt, that's all. Try with the latest 1.3 revision, it should work for you (and if it doesn't, please file a bug) |
It works until version 1.2.13 and not after that (that is 1.2.14 to 1.2.16) and 1.3beta7 (the newest version). I have seen that you did make a PR/fix, is that right? |
@tmundt yes, I merged the PR last week, this should be fixed |
@caitp ok, thank you! That is weird somehow. Must have a closer look on that. |
Why do you assign i and ii to selectedScopes.length and destroys the i within the for-next loop?
|
You're looking at old pre-fix code, dude! |
Ups... this was from the CDN-Link to version 1.3beta7 starting at line 21767... so they aren't updated? I just called it up @ //cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0-beta.7/angular.js |
Ok that is the same code starting at line 20619. And I tested also the other versions 1.2.15 and 1.2.14 also. |
Yeah, you're right. http://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.8/angular.js for (i = 0, ii = previousElements.length; i < ii; ++i) {
previousElements[i].remove();
}
previousElements.length = 0;
for (i = 0, ii = selectedScopes.length; i < ii; ++i) {
var selected = selectedElements[i];
selectedScopes[i].$destroy();
previousElements[i] = selected;
$animate.leave(selected, function() {
previousElements.splice(i, 1);
});
}
// ... |
There hasn't been a 1.2.x release in the past few weeks, so this is only in the 1.3 channel for now |
Oh ok. The code for version 1.3beta7 makes sense and my code is working after switching to your URL (and not using //cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0-beta.7/angular.js). Hope that your fix will be in the 1.2.x channel soon. |
Hi!
After upgrading to angular 1.2.16, we noticed a regression in the ngSwitch directive that seems to have been present since 1.2.14 and is also still present in 1.3.0 beta-7.
The issue occurs when two elements have the same ng-switch-when value. When toggling between values of the switch expression, angular will throw the following error when it tries to "hide" the elements having the same ng-switch-when.
The call stack produced by the error:
Reproduction:
Here is a js fiddle that reproduces this issue: http://jsfiddle.net/QZkZN/4/
(Click on "show edit", then "cancel", then "show edit" again to trigger the error.)
Reproducibility:
The bug is 100% reproductible on chrome latest - we haven't tried other browsers.
Source of the regression:
This line and the surrounding code introduced in commit e988199 (changes to file:
src/ng/directive/ngSwitch.js
) is causing the error:angular.js/src/ng/directive/ngSwitch.js
Line 149 in e988199
The text was updated successfully, but these errors were encountered: