fix(button): fill can be set to undefined (#26339)

resolves #25886
This commit is contained in:
Liam DeBeasi
2022-11-22 13:46:17 -05:00
committed by GitHub
parent 7ae8117284
commit 2fe23d9d46
2 changed files with 24 additions and 1 deletions

View File

@ -272,7 +272,11 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf
target, target,
}; };
let fill = this.fill; let fill = this.fill;
if (fill === undefined) { /**
* We check both undefined and null to
* work around https://github.com/ionic-team/stencil/issues/3586.
*/
if (fill == null) {
fill = this.inToolbar || this.inListHeader ? 'clear' : 'solid'; fill = this.inToolbar || this.inListHeader ? 'clear' : 'solid';
} }
return ( return (

View File

@ -9,6 +9,25 @@ test.describe('button: basic', () => {
expect(await page.screenshot()).toMatchSnapshot(`button-diff-${page.getSnapshotSettings()}.png`); expect(await page.screenshot()).toMatchSnapshot(`button-diff-${page.getSnapshotSettings()}.png`);
}); });
test('should correctly set fill to undefined', async ({ page, skip }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/25886',
});
skip.rtl();
skip.mode('ios', 'This behavior does not differ across modes');
await page.setContent(`
<ion-button fill="outline"></ion-button>
`);
const button = page.locator('ion-button');
await expect(button).toHaveClass(/button-outline/);
await button.evaluate((el: HTMLIonButtonElement) => (el.fill = undefined));
await page.waitForChanges();
await expect(button).toHaveClass(/button-solid/);
});
}); });
test.describe('button: ripple effect', () => { test.describe('button: ripple effect', () => {