Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Fix for issue #5587 where app is bootstrapped more than once #5863

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/angular.suffix
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//try to bind to jquery now so that one can write angular.element().read()
//but we will rebind on bootstrap again.
if (window.angular.bootstrap) {
//already bootstrapped, so we can return here...
return;
}

bindJQuery();

publishExternalAPI(angular);
Expand Down
14 changes: 6 additions & 8 deletions src/ng/directive/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,12 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
selected: selected // determine if we should be selected
});
}
if (!multiple) {
if (nullOption || modelValue === null) {
// insert null option if we have a placeholder, or the model is null
optionGroups[''].unshift({id:'', label:'', selected:!selectedSet});
} else if (!selectedSet) {
// option could not be found, we have to insert the undefined item
optionGroups[''].unshift({id:'?', label:'', selected:true});
}
if (nullOption || modelValue === null) {
// insert null option if we have a placeholder, or the model is null
optionGroups[''].unshift({id:'', label:'', selected:!selectedSet});
} else if (!selectedSet) {
// option could not be found, we have to insert the undefined item
optionGroups[''].unshift({id:'?', label:'', selected:true});
}

// Now we need to update the list of DOM nodes to match the optionGroups we computed above
Expand Down
34 changes: 34 additions & 0 deletions test/ng/directive/selectSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,40 @@ describe('select', function() {
});


it('should include static option', function() {
createMultiSelect('<option value="">Choose One</option>');

scope.$apply(function() {
scope.values = [{name: 'A'}, {name: 'B'}];
scope.selected = [];
});

expect(element.find('option').length).toEqual(3);
expect(element.find('option')[0].selected).toBeFalsy();
expect(element.find('option')[1].selected).toBeFalsy();
expect(element.find('option')[2].selected).toBeFalsy();

scope.$apply(function() {
scope.selected.push(scope.values[0]);
});

expect(element.find('option').length).toEqual(3);

expect(element.find('option')[0].selected).toBeFalsy();
expect(element.find('option')[1].selected).toBeTruthy();
expect(element.find('option')[2].selected).toBeFalsy();

scope.$apply(function() {
scope.selected.push(scope.values[1]);
});

expect(element.find('option').length).toEqual(3);
expect(element.find('option')[0].selected).toBeFalsy();
expect(element.find('option')[1].selected).toBeTruthy();
expect(element.find('option')[2].selected).toBeTruthy();
});


it('should update model on change', function() {
createMultiSelect();

Expand Down