From b8897dba6f3b633dc87f36c8b2e938c0185864dd Mon Sep 17 00:00:00 2001 From: Ryan Schmukler Date: Sun, 28 Jun 2015 15:39:34 -0400 Subject: [PATCH] feat(select): add md-container-class for custom styling closes #3116 --- src/components/select/select.js | 2 ++ src/components/select/select.spec.js | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/components/select/select.js b/src/components/select/select.js index 7220cf4ac1a..61607dbd2e1 100755 --- a/src/components/select/select.js +++ b/src/components/select/select.js @@ -45,6 +45,7 @@ angular.module('material.components.select', [ * @param {expression=} md-on-close expression to be evaluated when the select is closed * @param {string=} placeholder Placeholder hint text. * @param {string=} aria-label Optional label for accessibility. Only necessary if no placeholder or + * @param {string=} md-container-class class list to get applied to the .md-select-menu-container element (for custom styling) * explicit label is present. * * @usage @@ -336,6 +337,7 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $interpolate, selectEl.data('$mdSelectController', mdSelectCtrl); selectScope = scope.$new(); $mdTheming.inherit(selectContainer, element); + selectContainer[0].setAttribute('class', selectContainer[0].getAttribute('class') + ' ' + element.attr('md-container-class')); selectContainer = $compile(selectContainer)(selectScope); selectMenuCtrl = selectContainer.find('md-select-menu').controller('mdSelectMenu'); } diff --git a/src/components/select/select.spec.js b/src/components/select/select.spec.js index 681f9f8093a..192f2b218f5 100755 --- a/src/components/select/select.spec.js +++ b/src/components/select/select.spec.js @@ -113,6 +113,14 @@ describe('', function() { expect(select.attr('aria-disabled')).toBe('true'); })); + it('supports passing classes to the container', inject(function($document) { + var select = setupSelect('ng-model="val", 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('closes the menu if the element is destroyed', inject(function($document, $rootScope) { var called = false; $rootScope.onClose = function() {