mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 18:54:11 +08:00
refactor(all): strict boolean conditions
This commit is contained in:
@ -108,22 +108,22 @@ export class Button {
|
||||
}
|
||||
}
|
||||
|
||||
onFocus() {
|
||||
private onFocus() {
|
||||
this.ionFocus.emit();
|
||||
}
|
||||
|
||||
onKeyUp() {
|
||||
private onKeyUp() {
|
||||
this.keyFocus = true;
|
||||
}
|
||||
|
||||
onBlur() {
|
||||
private onBlur() {
|
||||
this.keyFocus = false;
|
||||
this.ionBlur.emit();
|
||||
}
|
||||
|
||||
onClick(ev: Event) {
|
||||
private onClick(ev: Event) {
|
||||
if (this.type === 'button') {
|
||||
openURL(this.win, this.href, ev, this.routerDirection);
|
||||
return openURL(this.win, this.href, ev, this.routerDirection);
|
||||
|
||||
} else if (hasShadowDom(this.el)) {
|
||||
// this button wants to specifically submit a form
|
||||
@ -142,6 +142,7 @@ export class Button {
|
||||
fakeButton.remove();
|
||||
}
|
||||
}
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
hostData() {
|
||||
@ -163,7 +164,7 @@ export class Button {
|
||||
|
||||
protected render() {
|
||||
|
||||
const TagType = this.href ? 'a' : 'button';
|
||||
const TagType = this.href === undefined ? 'button' : 'a';
|
||||
const attrs = (TagType === 'button')
|
||||
? { type: this.type }
|
||||
: { href: this.href };
|
||||
@ -194,7 +195,7 @@ export class Button {
|
||||
* e.g. alert-button, action-sheet-button
|
||||
*/
|
||||
function getButtonClassMap(buttonType: string | undefined, mode: Mode): CssClassMap {
|
||||
if (!buttonType) {
|
||||
if (buttonType === undefined) {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
@ -208,7 +209,7 @@ function getButtonClassMap(buttonType: string | undefined, mode: Mode): CssClass
|
||||
* e.g. block, full, round, large
|
||||
*/
|
||||
function getButtonTypeClassMap(buttonType: string, type: string | undefined, mode: Mode): CssClassMap {
|
||||
if (!type) {
|
||||
if (type === undefined) {
|
||||
return {};
|
||||
}
|
||||
type = type.toLocaleLowerCase();
|
||||
@ -221,7 +222,7 @@ function getButtonTypeClassMap(buttonType: string, type: string | undefined, mod
|
||||
function getColorClassMap(buttonType: string, color: string | undefined, fill: string | undefined, mode: Mode): CssClassMap {
|
||||
let className = buttonType;
|
||||
|
||||
if (fill) {
|
||||
if (fill !== undefined) {
|
||||
className += `-${fill.toLowerCase()}`;
|
||||
}
|
||||
|
||||
@ -229,7 +230,7 @@ function getColorClassMap(buttonType: string, color: string | undefined, fill: s
|
||||
[className]: true,
|
||||
[`${className}-${mode}`]: true,
|
||||
};
|
||||
if (color) {
|
||||
if (color !== undefined) {
|
||||
map[`ion-color-${color}`] = true;
|
||||
}
|
||||
return map;
|
||||
|
Reference in New Issue
Block a user