Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

docs(select): clarify behavior of multiple attribute #11316

Merged
merged 1 commit into from
Jun 22, 2018
Merged
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
6 changes: 4 additions & 2 deletions src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ angular.module('material.components.select', [
*
* @param {expression} ng-model Assignable angular expression to data-bind to.
* @param {expression=} ng-change Expression to be executed when the model value changes.
* @param {boolean=} multiple When set to true, allows for more than one option to be selected. The model is an array with the selected choices.
* @param {boolean=} multiple When present, allows for more than one option to be selected.
* The model is an array with the selected choices. **Note:** This attribute is only evaluated
* once; it is not watched.
* @param {expression=} md-on-close Expression to be evaluated when the select is closed.
* @param {expression=} md-on-open Expression to be evaluated when opening the select.
* Will hide the select options and show a spinner until the evaluated promise resolves.
Expand All @@ -83,7 +85,7 @@ angular.module('material.components.select', [
* will be treated as *html*. The value must either be explicitly marked as trustedHtml or
* the ngSanitize module must be loaded.
* @param {string=} placeholder Placeholder hint text.
* @param md-no-asterisk {boolean=} When set to true, an asterisk will not be appended to the
* @param {boolean=} md-no-asterisk When set to true, an asterisk will not be appended to the
* floating label. **Note:** This attribute is only evaluated once; it is not watched.
* @param {string=} aria-label Optional label for accessibility. Only necessary if no placeholder or
* explicit label is present.
Expand Down
20 changes: 15 additions & 5 deletions src/components/select/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ describe('<md-select>', function() {
$rootScope.model = [];
$rootScope.opts = [1, 2, 3, 4];
$compile('<form name="testForm">' +
'<md-select ng-model="model" name="multiSelect" required="required" multiple="multiple">' +
'<md-select ng-model="model" name="multiSelect" required="required" multiple>' +
'<md-option ng-repeat="opt in opts" ng-value="opt"></md-option>' +
'</md-select></form>')($rootScope);
$rootScope.$digest();
Expand Down Expand Up @@ -1078,7 +1078,7 @@ describe('<md-select>', function() {
$rootScope.model = [1, 2];
$rootScope.opts = [1, 2, 3, 4];
$compile('<form name="testForm">' +
'<md-select ng-model="model" name="multiSelect" multiple="multiple">' +
'<md-select ng-model="model" name="multiSelect" multiple>' +
'<md-option ng-repeat="opt in opts" ng-value="opt"></md-option>' +
'</md-select></form>')($rootScope);
$rootScope.$digest();
Expand Down Expand Up @@ -1193,8 +1193,18 @@ describe('<md-select>', function() {
expect($rootScope.model).toEqual([1,3]);
});

it('should not be multiple if attr.multiple == `false`', function() {
var el = setupSelect('multiple="false" ng-model="$root.model"').find('md-select');
it('should be multiple if attr.multiple exists', function() {
var el = setupSelect('multiple ng-model="$root.model"').find('md-select');
openSelect(el);
expectSelectOpen(el);

var selectMenu = $document.find('md-select-menu')[0];

expect(selectMenu.hasAttribute('multiple')).toBe(true);
});

it('should not be multiple if attr.multiple does not exist', function() {
var el = setupSelect('ng-model="$root.model"').find('md-select');
openSelect(el);
expectSelectOpen(el);

Expand All @@ -1207,7 +1217,7 @@ describe('<md-select>', function() {
$rootScope.model = 2;
$rootScope.opts = [1, 2, 3, 4];
var form = $compile('<form name="testForm">' +
'<md-select multiple="multiple" ng-model="model" name="multiSelect">' +
'<md-select multiple ng-model="model" name="multiSelect">' +
'<md-option ng-repeat="opt in opts" ng-value="opt">{{opt}}</md-option>' +
'</md-select></form>')($rootScope);
var el = form.find('md-select');
Expand Down