@@ -185,16 +185,40 @@ class MaterialDropdownSelectComponent extends MaterialSelectBase
185185 @Input ()
186186 ComponentRenderer labelRenderer;
187187
188+ /// CSS classes from the root element, passed to the popup to allow scoping of
189+ /// mixins.
190+ ///
191+ /// Only visible for the template.
192+ final String popupClassName;
193+
188194 MaterialDropdownSelectComponent (
189195 @Optional () IdGenerator idGenerator,
190196 @Optional () @SkipSelf () this ._popupSizeDelegate,
191- @Optional () @Inject (rtlToken) bool rtl)
192- : activeModel = new ActiveItemModel (idGenerator) {
197+ @Optional () @Inject (rtlToken) bool rtl,
198+ @Attribute ('popupClass' ) String popupClass,
199+ HtmlElement element)
200+ : activeModel = new ActiveItemModel (idGenerator),
201+ popupClassName =
202+ _constructEncapsulatedCss (popupClass, element.classes) {
193203 isRtl = rtl;
194204 preferredPositions = RelativePosition .overlapAlignments;
195205 iconName = 'arrow_drop_down' ;
196206 }
197207
208+ /// Return a string representing the encapsulated classes from [classes]
209+ /// combined with the classes from [className] .
210+ // TODO(google): Move this somewhere more common if this becomes common
211+ // practice.
212+ static String _constructEncapsulatedCss (
213+ String className, CssClassSet classes) {
214+ var result = className ?? '' ;
215+ for (var i in classes) {
216+ // Add encapsulation classes from host
217+ if (i.startsWith ('_' )) result += ' $i ' ;
218+ }
219+ return result;
220+ }
221+
198222 @Input ()
199223 @override
200224 set componentRenderer (ComponentRenderer value) {
0 commit comments