-
Notifications
You must be signed in to change notification settings - Fork 27.4k
'select' / 'ng-model' / 'ng-options' behaviour changed in 1.4.9 #14115
Comments
Do I understand correctly that only the test fails, but the select behaves correctly inside the app? |
Ok, so for some reason if the first option is selected, the selected attribute is not set on it. But apart from that, everything seems to work correctly. It was introduced by this change apparently: f7eab8d |
This happens because (as an optimization) we check if |
@gkalpak I changed our test to use the 'select' tag api ('selectedIndex' and 'value') instead of using the 'selected' DOM attribute and seems to work ok, so I guess that is a more reliable way :) Thanks!! |
@almilo, I rather think we should fix this in Angular. It's a bug imo. var opt = $('[value="' + selectElement.val() + '"]');
expect(opt.prop('selected')).toBe(true);
expect(opt.text()).toBe(...); |
You can also get the option that should be selected by index: |
@gkalpak I'm not sure why it breaks with 1.4.9, because the line you've linked has been in the code for a year. |
@gkalpak if my opinion counts, it is a change in an expected behaviour, so yes it is a regression bug. Many thanks guys!! |
So there's two things going on:
|
Wow, that's pretty unexpected behavior ftom jqLite 😕 |
We don't set selected property / attribute on options that are already selected. That happens for example if the browser has automatically selected the first option in a select. In that case, the selected property is set automatically, but the selected attribute is not Closes angular#14115
The code for that is very old - I suppose (hope) it's an workaround for IE <= 8 |
We don't set selected property / attribute on options that are already selected. That happens for example if the browser has automatically selected the first option in a select. In that case, the selected property is set automatically, but the selected attribute is not Closes angular#14115
We don't set selected property / attribute on options that are already selected. That happens for example if the browser has automatically selected the first option in a select. In that case, the selected property is set automatically, but the selected attribute is not Closes angular#14115
jQuery has a boolHook that changes P.S. Please press |
Nice trick with the |
@Narretz Sure, assign it to me, I'll have a look. |
Checking for the |
We don't set selected property / attribute on options that are already selected. That happens for example if the browser has automatically selected the first option in a select. In that case, the selected property is set automatically, but the selected attribute is not Closes #14115
We don't set selected property / attribute on options that are already selected. That happens for example if the browser has automatically selected the first option in a select. In that case, the selected property is set automatically, but the selected attribute is not Closes #14115
Dear angular guys,
after upgrading AngularJS from version 1.4.8 to 1.4.9 some unit tests in our project related with basic functionality of the 'select' / 'ng-options' / 'ng-model' directives are broken. When using 1.4.9 with a 'select' tag with 'ng-options' and 'ng-model', the corresponding option does not seem to be selected in the unit test.
Reproducible: always
Browsers: Chrome 45, Firefox 43
Operating system: Mac OS X Yosemite (10.10.3)
Steps to reproduce:
see plunker http://plnkr.co/edit/wlgE9zrTduqhlG0i8oGT?p=preview (first plunker version - angularjs 1.4.8 OK, last plunker version angularjs 1.4.9 NOK)
The text was updated successfully, but these errors were encountered: