From 35aa56d334fea807a1f94c78ccc8ab69c6571e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BCnyamin=20Eskiocak?= <37407974+bunesk@users.noreply.github.com> Date: Wed, 30 Nov 2022 23:42:56 +0300 Subject: [PATCH] Added title attribute (#1043) * added title attribute Fixes #1042 * added tests for title * also some other tests * clarify why title was added --- src/components/button/button.test.ts | 8 ++++++ src/components/button/button.ts | 4 ++- src/components/checkbox/checkbox.test.ts | 25 +++++++++++++++++ src/components/checkbox/checkbox.ts | 8 ++++-- src/components/input/input.test.ts | 8 ++++++ src/components/input/input.ts | 5 ++-- src/components/range/range.test.ts | 8 ++++++ src/components/range/range.ts | 14 ++++++---- src/components/switch/switch.test.ts | 24 ++++++++++++++++ src/components/switch/switch.ts | 8 ++++-- src/components/textarea/textarea.test.ts | 35 ++++++++++++++++++++++++ src/components/textarea/textarea.ts | 4 ++- 12 files changed, 135 insertions(+), 16 deletions(-) diff --git a/src/components/button/button.test.ts b/src/components/button/button.test.ts index 31daf8fc..dff552d1 100644 --- a/src/components/button/button.test.ts +++ b/src/components/button/button.test.ts @@ -23,6 +23,7 @@ describe('', () => { it('default values are set correctly', async () => { const el = await fixture(html` Button Label `); + expect(el.title).to.equal(''); expect(el.variant).to.equal('default'); expect(el.size).to.equal('medium'); expect(el.disabled).to.equal(false); @@ -88,6 +89,13 @@ describe('', () => { }); }); + it('should have title if title attribute isset', async () => { + const el = await fixture(html` `); + const button = el.shadowRoot!.querySelector('[part~="base"]')!; + + expect(button.title).to.equal('Test'); + }); + describe('when loading', () => { it('should have a spinner present', async () => { const el = await fixture(html` Button Label `); diff --git a/src/components/button/button.ts b/src/components/button/button.ts index a62d375b..065d963e 100644 --- a/src/components/button/button.ts +++ b/src/components/button/button.ts @@ -98,6 +98,8 @@ export default class SlButton extends ShoelaceElement implements ShoelaceFormCon /** An optional value for the button. Ignored when `href` is set. */ @property() value = ''; + @property() title = ''; // make reactive to pass through + /** When set, the underlying button will be rendered as an `` with this `href` instead of a `