From 7b01261b5a0c078c8fa42b239cd4a9d078af402a Mon Sep 17 00:00:00 2001 From: Chris Akinrinade <72534276+chrisakinrinade@users.noreply.github.com> Date: Mon, 7 Jun 2021 13:49:23 -0400 Subject: [PATCH] renamed push/pop to add/delete, fixed hyperlink underline --- app/ids-breadcrumb/add-remove.js | 4 ++-- app/ids-breadcrumb/standalone-css.html | 6 +++--- src/ids-breadcrumb/ids-breadcrumb.js | 12 ++++++++---- src/ids-hyperlink/ids-hyperlink.scss | 2 +- .../ids-breadcrumb-func-test.js | 19 ++++++++++--------- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/app/ids-breadcrumb/add-remove.js b/app/ids-breadcrumb/add-remove.js index c36475f4d4..cb8e0db749 100644 --- a/app/ids-breadcrumb/add-remove.js +++ b/app/ids-breadcrumb/add-remove.js @@ -13,7 +13,7 @@ button1.onclick = () => { link.innerText = `Breadcrumb ${breadcrumb.children.length + 1}`; link.href = '#'; if (checkbox.checked) link.disabled = ''; - breadcrumb.push(link); + breadcrumb.add(link); }; -button2.onclick = () => breadcrumb.pop(); +button2.onclick = () => breadcrumb.delete(); diff --git a/app/ids-breadcrumb/standalone-css.html b/app/ids-breadcrumb/standalone-css.html index 9b9b448246..1da7214f4e 100644 --- a/app/ids-breadcrumb/standalone-css.html +++ b/app/ids-breadcrumb/standalone-css.html @@ -4,9 +4,9 @@
- First Breadcrumb - Breadcrumb - No href - Disabled + First Breadcrumb + Breadcrumb - No href + Disabled
{{> ../layouts/footer.html }} diff --git a/src/ids-breadcrumb/ids-breadcrumb.js b/src/ids-breadcrumb/ids-breadcrumb.js index d8f928c565..27e2fa0ef4 100644 --- a/src/ids-breadcrumb/ids-breadcrumb.js +++ b/src/ids-breadcrumb/ids-breadcrumb.js @@ -33,8 +33,10 @@ class IdsBreadcrumb extends mix(IdsElement).with(IdsEventsMixin, IdsThemeMixin) #init() { this.setAttribute('role', 'list'); const stack = []; - while (this.lastElementChild) { stack.push(this.pop()); } - while (stack.length) { this.push(stack.pop()); } + /* istanbul ignore next */ + while (this.lastElementChild) { stack.push(this.delete()); } + /* istanbul ignore next */ + while (stack.length) { this.add(stack.pop()); } } /** @@ -54,13 +56,15 @@ class IdsBreadcrumb extends mix(IdsElement).with(IdsEventsMixin, IdsThemeMixin) * Appends an individual breadcrumb to the end of the stack * @param {Element} breadcrumb The HTML element with which to add */ - push(breadcrumb) { + add(breadcrumb) { if (this.lastElementChild) { this.lastElementChild.setAttribute('font-weight', ''); } breadcrumb.setAttribute('font-weight', 'bolder'); breadcrumb.setAttribute('color', 'unset'); breadcrumb.setAttribute('role', 'listitem'); + breadcrumb.setAttribute('text-decoration', 'none'); + /* istanbul ignore next */ if (!(breadcrumb.getAttribute('font-size'))) { breadcrumb.setAttribute('font-size', 14); } @@ -71,7 +75,7 @@ class IdsBreadcrumb extends mix(IdsElement).with(IdsEventsMixin, IdsThemeMixin) * Removes the last breadcrumb from the stack. * @returns {Element | null} The removed element */ - pop() { + delete() { if (this.lastElementChild) { const breadcrumb = this.removeChild(this.lastElementChild); if (this.lastElementChild) { diff --git a/src/ids-hyperlink/ids-hyperlink.scss b/src/ids-hyperlink/ids-hyperlink.scss index 7b7bd60ec1..8214fc2dcb 100644 --- a/src/ids-hyperlink/ids-hyperlink.scss +++ b/src/ids-hyperlink/ids-hyperlink.scss @@ -42,7 +42,7 @@ } } -a.ids-hyperlink { +[text-decoration='none'] { text-decoration: none; } diff --git a/test/ids-breadcrumb/ids-breadcrumb-func-test.js b/test/ids-breadcrumb/ids-breadcrumb-func-test.js index 7b5e5a6620..393e622d51 100644 --- a/test/ids-breadcrumb/ids-breadcrumb-func-test.js +++ b/test/ids-breadcrumb/ids-breadcrumb-func-test.js @@ -20,15 +20,16 @@ describe('IdsBreadcrumb Component', () => { it('renders with no errors', () => { const errors = jest.spyOn(global.console, 'error'); const elem = new IdsBreadcrumb(); + expect(document.querySelectorAll('ids-breadcrumb').length).toEqual(1); document.body.appendChild(elem); elem.remove(); expect(document.querySelectorAll('ids-breadcrumb').length).toEqual(1); expect(errors).not.toHaveBeenCalled(); }); - it('pushes new crumbs onto the stack', () => { - breadcrumb.push(new IdsHyperlink()); - breadcrumb.push(new IdsHyperlink()); + it('adds new crumbs onto the stack', () => { + breadcrumb.add(new IdsHyperlink()); + breadcrumb.add(new IdsHyperlink()); expect(breadcrumb.children.length).toEqual(2); for (const child of breadcrumb.children) { expect(child.getAttribute('color')).toEqual('unset'); @@ -38,15 +39,15 @@ describe('IdsBreadcrumb Component', () => { expect(breadcrumb.lastElementChild.getAttribute('font-weight')).toEqual('bolder'); }); - it('pops breadcrumb off the stack and returns it', () => { - breadcrumb.push(new IdsHyperlink()); - breadcrumb.push(new IdsHyperlink()); - expect(breadcrumb.pop() instanceof IdsHyperlink).toEqual(true); + it('removes breadcrumb off the stack and returns it', () => { + breadcrumb.add(new IdsHyperlink()); + breadcrumb.add(new IdsHyperlink()); + expect(breadcrumb.delete() instanceof IdsHyperlink).toEqual(true); expect(breadcrumb.children.length).toEqual(1); expect(breadcrumb.lastElementChild.fontWeight).toEqual('bolder'); - breadcrumb.pop(); + breadcrumb.delete(); expect(breadcrumb.children.length).toEqual(0); - expect(breadcrumb.pop()).toEqual(null); + expect(breadcrumb.delete()).toEqual(null); }); it('renders correctly', () => {