Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add Optional swiperElementNodeName Prop for (non swiper-element) Web Component Usage #7284

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components-shared/params-list.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const paramsList = [
'init',
'_direction',
'oneWayMovement',
'swiperElementNodeName',
'touchEventsTarget',
'initialSlide',
'_speed',
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ class Swiper {
}

el.swiper = swiper;
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === 'SWIPER-CONTAINER') {
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
swiper.isElement = true;
}

Expand Down
1 change: 1 addition & 0 deletions src/core/defaults.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
init: true,
direction: 'horizontal',
oneWayMovement: false,
swiperElementNodeName: 'SWIPER-CONTAINER',
touchEventsTarget: 'wrapper',
initialSlide: 0,
speed: 300,
Expand Down
4 changes: 4 additions & 0 deletions src/swiper-vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ declare const Swiper: DefineComponent<
type: PropType<SwiperOptions['oneWayMovement']>;
default: SwiperOptions['oneWayMovement'];
};
swiperElementNodeName: {
type: PropType<SwiperOptions['swiperElementNodeName']>;
default: SwiperOptions['swiperElementNodeName'];
};
touchEventsTarget: {
type: PropType<SwiperOptions['touchEventsTarget']>;
default: undefined;
Expand Down
7 changes: 7 additions & 0 deletions src/types/swiper-options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ export interface SwiperOptions {

oneWayMovement?: boolean;

/**
* The name of the swiper element node name; used for detecting web component rendering
*
* @default 'SWIPER-CONTAINER'
*/
swiperElementNodeName?: string;

/**
* Duration of transition between slides (in ms)
*
Expand Down
1 change: 1 addition & 0 deletions src/vue/swiper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Swiper = {
init: { type: Boolean, default: undefined },
direction: { type: String, default: undefined },
oneWayMovement: { type: Boolean, default: undefined },
swiperElementNodeName: { type: String, default: 'SWIPER-CONTAINER' },
touchEventsTarget: { type: String, default: undefined },
initialSlide: { type: Number, default: undefined },
speed: { type: Number, default: undefined },
Expand Down