Skip to content

Commit f2ea80c

Browse files
aomarkscopybara-github
authored andcommitted
Return ClassInfo instead of a DirectiveResult from mwc-button's getRenderClasses() method.
1. It allows subclasses to augment the classes. 2. It avoids an issue relating to relying on the implied type of Directive results, due to a bug in tsc (see #2715 and microsoft/TypeScript#45946) PiperOrigin-RevId: 397790019
1 parent 1de87bb commit f2ea80c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/button/mwc-button-base.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {AriaHasPopup, ariaProperty} from '@material/mwc-base/aria-property';
1414
import {Ripple} from '@material/mwc-ripple/mwc-ripple';
1515
import {RippleHandlers} from '@material/mwc-ripple/ripple-handlers';
1616
import {eventOptions, html, LitElement, property, query, queryAsync, state, TemplateResult} from 'lit-element';
17-
import {classMap} from 'lit-html/directives/class-map.js';
17+
import {classMap, ClassInfo} from 'lit-html/directives/class-map.js';
1818
import {ifDefined} from 'lit-html/directives/if-defined.js';
1919

2020
/** @soyCompatible */
@@ -88,14 +88,14 @@ export class ButtonBase extends LitElement {
8888
}
8989
}
9090

91-
/** @soyTemplate classMap */
92-
protected getRenderClasses() {
93-
return classMap({
91+
/** @soyTemplate */
92+
protected getRenderClasses(): ClassInfo {
93+
return {
9494
'mdc-button--raised': this.raised,
9595
'mdc-button--unelevated': this.unelevated,
9696
'mdc-button--outlined': this.outlined,
9797
'mdc-button--dense': this.dense,
98-
});
98+
};
9999
}
100100

101101
/**
@@ -107,7 +107,7 @@ export class ButtonBase extends LitElement {
107107
return html`
108108
<button
109109
id="button"
110-
class="mdc-button ${this.getRenderClasses()}"
110+
class="mdc-button ${classMap(this.getRenderClasses())}"
111111
?disabled="${this.disabled}"
112112
aria-label="${this.label || this.icon}"
113113
aria-haspopup="${ifDefined(this.ariaHasPopup)}"

0 commit comments

Comments
 (0)