fix(select): re-define ngModelCtrl.$render in the select postLink fn
Previously, the `$render` function was re-defined in the `select` directive's `preLink` function. When a `select` element is compiled, every `option` element inside it is linked and registered with the `selectCtrl`, which calls `$render` to update the selected `option`. `$render` calls `selectCtrl.writeValue`, which adds an unknown `option` in case no option is selected. In cases where `optgroup` elements are followed by a line-break, adding the unknown `option` confuses the html compiler and makes it call the link function of the following `option` with a wrong element, which means this option is not correctly registered. Since manipulation of the DOM in the `preLink` function is wrong API usage, the problem cannot be fixed in the compiler. With this commit, the `$render` function is not re-defined until the `select` directive's `postLink` function, at which point all `option` elements have been linked already. The commit also changes the `toEqualSelectWithOptions` matcher to take selected options in groups into account. Closes #13583 Closes #13583 Closes #13663
M
Martin Staffa committed
f7eab8d8fe8cadecaee425f0db0c74e48619310c
Parent: 495d40d
Committed by Peter Bacon Darwin <pete@bacondarwin.com>
on 1/7/2016, 12:06:13 PM