@@ -9,7 +9,6 @@ import '../../ripple/ripple.js';
99
1010import { html , isServer , LitElement , nothing } from 'lit' ;
1111import { property , query , queryAssignedElements } from 'lit/decorators.js' ;
12- import { literal , html as staticHtml } from 'lit/static-html.js' ;
1312
1413import { ARIAMixinStrict } from '../../internal/aria/aria.js' ;
1514import { requestUpdateOnAriaChange } from '../../internal/aria/delegate.js' ;
@@ -118,28 +117,40 @@ export abstract class Button extends buttonBaseClass implements FormSubmitter {
118117 }
119118
120119 protected override render ( ) {
121- // Link buttons may not be disabled
122- const isDisabled = this . disabled && ! this . href ;
123-
124- const button = this . href ? literal `a` : literal `button` ;
125- // Needed for closure conformance
126- const { ariaLabel, ariaHasPopup, ariaExpanded} = this as ARIAMixinStrict ;
127- return staticHtml `
128- < ${ button }
129- class ="button"
130- ?disabled=${ isDisabled }
131- aria-label="${ ariaLabel || nothing } "
132- aria-haspopup="${ ariaHasPopup || nothing } "
133- aria-expanded="${ ariaExpanded || nothing } "
134- href=${ this . href || nothing }
135- target=${ this . target || nothing }
136- > ${ this . renderContent ( ) } </ ${ button } > ` ;
120+ return this . href ? this . renderLink ( ) : this . renderButton ( ) ;
137121 }
138122
139123 protected renderElevation ?( ) : unknown ;
140124
141125 protected renderOutline ?( ) : unknown ;
142126
127+ private renderButton ( ) {
128+ // Needed for closure conformance
129+ const { ariaLabel, ariaHasPopup, ariaExpanded} = this as ARIAMixinStrict ;
130+ return html `< button
131+ id ="button "
132+ class ="button "
133+ ?disabled =${ this . disabled }
134+ aria-label ="${ ariaLabel || nothing } "
135+ aria-haspopup="${ ariaHasPopup || nothing } "
136+ aria-expanded="${ ariaExpanded || nothing } ">
137+ ${ this . renderContent ( ) }
138+ </ button > ` ;
139+ }
140+
141+ private renderLink ( ) {
142+ // Needed for closure conformance
143+ const { ariaLabel} = this as ARIAMixinStrict ;
144+ return html `< a
145+ id ="link "
146+ class ="button "
147+ aria-label ="${ ariaLabel || nothing } "
148+ href =${ this . href }
149+ target =${ this . target || nothing }
150+ > ${ this . renderContent ( ) }
151+ </ a > ` ;
152+ }
153+
143154 private renderContent ( ) {
144155 // Link buttons may not be disabled
145156 const isDisabled = this . disabled && ! this . href ;
0 commit comments