Skip to content

Commit

Permalink
Extend fix from #1208 to all browsers since Firefox also has a proble…
Browse files Browse the repository at this point in the history
…m with selection when deleting options first.
  • Loading branch information
mbest committed Feb 12, 2014
1 parent 67e5094 commit 7749397
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion spec/defaultBindings/optionsBehaviors.js
Expand Up @@ -97,7 +97,7 @@ describe('Binding: Options', function() {
});

it('Should select first option when removing the selected option and the original first option', function () {
// This test failed in IE<=8 without changes made in #1208
// This test failed in IE<=8 and Firefox without changes made in #1208
testNode.innerHTML = '<select data-bind="options: filterValues, optionsText: \'x\', optionsValue: \'x\'">';
var viewModel = {
filterValues: ko.observableArray([{x:1},{x:2},{x:3}])
Expand Down
12 changes: 5 additions & 7 deletions src/binding/defaultBindings/options.js
Expand Up @@ -90,13 +90,11 @@ ko.bindingHandlers['options'] = {
}

// By using a beforeRemove callback, we delay the removal until after new items are added. This fixes a selection
// problem in IE<=8. See https://github.com/knockout/knockout/issues/1208
if (ko.utils.ieVersion <= 8) {
arrayToDomNodeChildrenOptions['beforeRemove'] =
function (option) {
element.removeChild(option);
};
}
// problem in IE<=8 and Firefox. See https://github.com/knockout/knockout/issues/1208
arrayToDomNodeChildrenOptions['beforeRemove'] =
function (option) {
element.removeChild(option);
};

function setSelectionCallback(arrayEntry, newOptions) {
// IE6 doesn't like us to assign selection to OPTION nodes before they're added to the document.
Expand Down

0 comments on commit 7749397

Please sign in to comment.