forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 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 angular#13583
- Loading branch information
Showing
2 changed files
with
113 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters