Skip to content

Commit

Permalink
feat(element): add part="bullet[-active]" to pagination bullets
Browse files Browse the repository at this point in the history
fixes #6717
  • Loading branch information
nolimits4web committed Jun 7, 2023
1 parent 883f006 commit 8b4cccd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/modules/pagination/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ export default function Pagination({ swiper, extendParams, on, emit }) {
const bulletIndex = elementIndex(bullet);
if (bulletIndex === current) {
bullet.classList.add(...params.bulletActiveClass.split(' '));
} else if (swiper.isElement) {
bullet.setAttribute('part', 'bullet');
}
if (params.dynamicBullets) {
if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) {
Expand All @@ -189,7 +191,11 @@ export default function Pagination({ swiper, extendParams, on, emit }) {
if (bullet) {
bullet.classList.add(...params.bulletActiveClass.split(' '));
}

if (swiper.isElement) {
bullets.forEach((bulletEl, bulletIndex) => {
bulletEl.setAttribute('part', bulletIndex === current ? 'bullet-active' : 'bullet');
});
}
if (params.dynamicBullets) {
const firstDisplayedBullet = bullets[firstIndex];
const lastDisplayedBullet = bullets[lastIndex];
Expand Down Expand Up @@ -283,7 +289,8 @@ export default function Pagination({ swiper, extendParams, on, emit }) {
if (params.renderBullet) {
paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass);
} else {
paginationHTML += `<${params.bulletElement} class="${params.bulletClass}"></${params.bulletElement}>`;
// prettier-ignore
paginationHTML += `<${params.bulletElement} ${swiper.isElement ? 'part="bullet"' : ''} class="${params.bulletClass}"></${params.bulletElement}>`;
}
}
}
Expand Down

0 comments on commit 8b4cccd

Please sign in to comment.