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

fix(select): use parsed attribute for md-container-class attribute #6976

Closed
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
4 changes: 2 additions & 2 deletions src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $compile, $par
element[0].querySelector('.md-select-menu-container')
);
selectScope = scope;
if (element.attr('md-container-class')) {
var value = selectContainer[0].getAttribute('class') + ' ' + element.attr('md-container-class');
if (attr.mdContainerClass) {
var value = selectContainer[0].getAttribute('class') + ' ' + attr.mdContainerClass;
selectContainer[0].setAttribute('class', value);
}
selectMenuCtrl = selectContainer.find('md-select-menu').controller('mdSelectMenu');
Expand Down
18 changes: 18 additions & 0 deletions src/components/select/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ describe('<md-select>', function() {
expect(container.classList.contains('test')).toBe(true);
}));

it('supports passing classes to the container using `data-` attribute prefix', inject(function($document) {
var select = setupSelect('ng-model="val", data-md-container-class="test"').find('md-select');
openSelect(select);

var container = $document[0].querySelector('.md-select-menu-container');
expect(container).toBeTruthy();
expect(container.classList.contains('test')).toBe(true);
}));

it('supports passing classes to the container using `x-` attribute prefix', inject(function($document) {
var select = setupSelect('ng-model="val", x-md-container-class="test"').find('md-select');
openSelect(select);

var container = $document[0].querySelector('.md-select-menu-container');
expect(container).toBeTruthy();
expect(container.classList.contains('test')).toBe(true);
}));

it('sets aria-owns between the select and the container', function() {
var select = setupSelect('ng-model="val"').find('md-select');
var ownsId = select.attr('aria-owns');
Expand Down