Skip to content

chore(button): remove attribute prefix check #7843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
12 changes: 5 additions & 7 deletions src/lib/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ export class MatButton extends _MatButtonMixinBase
implements OnDestroy, CanDisable, CanColor, CanDisableRipple {

/** Whether the button is round. */
_isRoundButton: boolean = this._hasAttributeWithPrefix('fab', 'mini-fab');
_isRoundButton: boolean = this._hasHostAttributes('mat-fab', 'mat-mini-fab');

/** Whether the button is icon button. */
_isIconButton: boolean = this._hasAttributeWithPrefix('icon-button');
_isIconButton: boolean = this._hasHostAttributes('mat-icon-button');

constructor(renderer: Renderer2,
elementRef: ElementRef,
Expand All @@ -161,18 +161,16 @@ export class MatButton extends _MatButtonMixinBase
return this.disableRipple || this.disabled;
}

/** Gets whether the button has one of the given attributes with a 'mat-' prefix. */
_hasAttributeWithPrefix(...unprefixedAttributeNames: string[]) {
/** Gets whether the button has one of the given attributes. */
_hasHostAttributes(...attributes: string[]) {
// If not on the browser, say that there are none of the attributes present.
// Since these only affect how the ripple displays (and ripples only happen on the client),
// detecting these attributes isn't necessary when not on the browser.
if (!this._platform.isBrowser) {
return false;
}

return unprefixedAttributeNames.some(suffix => {
return this._getHostElement().hasAttribute('mat-' + suffix);
});
return attributes.some(attribute => this._getHostElement().hasAttribute(attribute));
}
}

Expand Down