Skip to content

Commit

Permalink
fix(ng:options): compile null/blank option tag, select correct elemen…
Browse files Browse the repository at this point in the history
…t in the view when unknown option is present

Closes angular#562, angular#599
  • Loading branch information
TEHEK committed Oct 12, 2011
1 parent f9144f0 commit defa2c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/widget/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ angularWidget('select', function(element){
if (existingOption.id !== option.id) {
lastElement.val(existingOption.id = option.id);
}
if (existingOption.selected !== option.selected) {
if (existingOption.element.selected !== option.selected) {

This comment has been minimized.

Copy link
@TEHEK

TEHEK Oct 18, 2011

Author Owner

existingOption was taken from cache (optionGroupsCache). When user switches selection to something else, the existingOption.element.selected is changed, but existingOption.selected is not.

It worked well if there was no '?' element in optionGroups (added on line 343). When added, it caused existingOptions and optionGroups to grow. When user switched from '?' to something else, the optionGroups was shrinked by 1 element, but existingOptions was not. The compiler started replacing labels and ids in <option> tags, but the selection was not updated.

Jeez. This commit was like 8 symbols, but the explanation and debugging took sooo long :)

lastElement.prop('selected', (existingOption.selected = option.selected));
}
} else {
Expand Down

0 comments on commit defa2c2

Please sign in to comment.