From a880726e056df8a31c69549457c370e215594fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFs=20Boubault?= <7613286+Applelo@users.noreply.github.com> Date: Tue, 13 Feb 2024 22:37:27 +0100 Subject: [PATCH 1/7] fix marquee code focus --- docs/guide/marquee.md | 2 +- package.json | 2 +- packages/core/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guide/marquee.md b/docs/guide/marquee.md index 2c2df0c..95a095f 100644 --- a/docs/guide/marquee.md +++ b/docs/guide/marquee.md @@ -41,7 +41,7 @@ You can change some options from the component. import { Marquee } from 'compotes' const marquee = new Marquee('.c-marquee', { - init: true, // [!code focus:6] + init: true, // [!code focus:7] initEvents: true, fill: false, direction: 'right', diff --git a/package.json b/package.json index 5b55c51..0bd088c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@compotes/root", "type": "module", - "version": "0.9.1", + "version": "0.9.2", "private": "true", "packageManager": "pnpm@8.15.2", "description": "Components library focused on accessibility/customization", diff --git a/packages/core/package.json b/packages/core/package.json index 3802f89..fa0a8ea 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "compotes", "type": "module", - "version": "0.9.1", + "version": "0.9.2", "packageManager": "pnpm@8.15.1", "description": "Components library focused on accessibility/customization", "author": "Applelo", From 31f19755c928bc2f15f36fae730fa155d2bdc2ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFs=20Boubault?= <7613286+Applelo@users.noreply.github.com> Date: Wed, 14 Feb 2024 20:57:45 +0100 Subject: [PATCH 2/7] add destroy test --- package.json | 2 +- packages/core/package.json | 2 +- packages/core/src/components/drilldown.ts | 10 +- packages/core/src/components/dropdown.ts | 2 +- .../test/__snapshots__/collapse.test.ts.snap | 32 ++++++ .../core/test/__snapshots__/drag.test.ts.snap | 24 ++++ .../test/__snapshots__/drilldown.test.ts.snap | 105 ++++++++++++++++++ .../test/__snapshots__/dropdown.test.ts.snap | 30 +++++ .../test/__snapshots__/marquee.test.ts.snap | 33 ++++++ packages/core/test/collapse.test.ts | 9 ++ packages/core/test/components/collapse.html | 3 + packages/core/test/components/collapse.ts | 4 +- packages/core/test/components/drag.html | 3 + packages/core/test/components/drag.ts | 4 +- packages/core/test/components/drilldown.html | 3 + packages/core/test/components/drilldown.ts | 6 +- packages/core/test/components/dropdown.html | 3 + packages/core/test/components/dropdown.ts | 4 +- packages/core/test/components/marquee.html | 3 + packages/core/test/components/marquee.ts | 3 + packages/core/test/drag.test.ts | 9 ++ packages/core/test/drilldown.test.ts | 9 ++ packages/core/test/dropdown.test.ts | 9 ++ packages/core/test/helper/destroy.ts | 10 ++ packages/core/test/marquee.test.ts | 9 ++ pnpm-lock.yaml | 60 +++++----- 26 files changed, 346 insertions(+), 45 deletions(-) create mode 100644 packages/core/test/__snapshots__/collapse.test.ts.snap create mode 100644 packages/core/test/__snapshots__/drag.test.ts.snap create mode 100644 packages/core/test/__snapshots__/drilldown.test.ts.snap create mode 100644 packages/core/test/__snapshots__/dropdown.test.ts.snap create mode 100644 packages/core/test/__snapshots__/marquee.test.ts.snap create mode 100644 packages/core/test/helper/destroy.ts diff --git a/package.json b/package.json index 0bd088c..1826113 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "eslint": "^8.56.0", "playwright": "^1.41.2", "typescript": "^5.3.3", - "vite": "^5.1.1", + "vite": "^5.1.2", "vitepress": "1.0.0-rc.42", "vitest": "^1.2.2", "vue": "^3.4.19", diff --git a/packages/core/package.json b/packages/core/package.json index fa0a8ea..9a72333 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -70,7 +70,7 @@ "fast-glob": "^3.3.2", "lightningcss": "^1.23.0", "typescript": "^5.3.3", - "vite": "^5.1.1", + "vite": "^5.1.2", "vite-plugin-dts": "^3.7.2" } } diff --git a/packages/core/src/components/drilldown.ts b/packages/core/src/components/drilldown.ts index b753df1..6e350b7 100644 --- a/packages/core/src/components/drilldown.ts +++ b/packages/core/src/components/drilldown.ts @@ -392,12 +392,10 @@ export default class Drilldown extends Parent { nexts.forEach((next) => { next.removeAttribute('role') next.removeAttribute('aria-expanded') - if (!next.getAttribute('aria-controls')) { - const menu = next.parentElement?.querySelector('.c-drilldown-menu') - next.removeAttribute('aria-controls') - if (menu && menu.id.startsWith('c-')) - menu.removeAttribute('id') - } + next.removeAttribute('aria-controls') + const menu = next.parentElement?.querySelector('.c-drilldown-menu') + if (menu && menu.id.startsWith('c-id-')) + menu.removeAttribute('id') }) const elsBeenDisable = this.el.querySelectorAll('[data-c-hidden]') elsBeenDisable.forEach((el) => { diff --git a/packages/core/src/components/dropdown.ts b/packages/core/src/components/dropdown.ts index f5c14c8..0797dde 100644 --- a/packages/core/src/components/dropdown.ts +++ b/packages/core/src/components/dropdown.ts @@ -324,7 +324,7 @@ export default class Dropdown extends Parent { this.triggerEl.removeAttribute('aria-controls') } - if (this.menuEl && this.menuEl.id.startsWith('c-')) + if (this.menuEl && this.menuEl.id.startsWith('c-id-')) this.menuEl.removeAttribute('id') if (this.type === 'menu' && this.menuEl) { diff --git a/packages/core/test/__snapshots__/collapse.test.ts.snap b/packages/core/test/__snapshots__/collapse.test.ts.snap new file mode 100644 index 0000000..e330c83 --- /dev/null +++ b/packages/core/test/__snapshots__/collapse.test.ts.snap @@ -0,0 +1,32 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`collapse > destroy 1`] = ` +"
+ + + ++ Lorem ipsum dolor sit amet consectetur, adipisicing elit. Mollitia facere possimus impedit facilis culpa illo earum deserunt consequuntur minus. Ad et qui labore reprehenderit magnam exercitationem placeat magni nesciunt suscipit. +
+Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur, id? Dolorum cum est ipsum praesentium mollitia quod saepe nemo doloribus, aliquid dolore laudantium consequuntur alias facere veritatis magni, adipisci fugit.
+Lorem ipsum dolor sit, amet consectetur adipisicing elit. Pariatur, est dolore. Vel ducimus incidunt labore, ipsum necessitatibus omnis qui! Consectetur molestiae ipsam repellendus illum hic veritatis. Consequuntur impedit animi voluptatum.
+