vanilla-jui 1.7.22 → 1.7.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-jui",
3
- "version": "1.7.22",
3
+ "version": "1.7.23",
4
4
  "private": false,
5
5
  "description": "A lightweight, reactive, and fully customizable vanilla JS UI library.",
6
6
  "keywords": [
@@ -259,6 +259,18 @@ function cloneData(data: SwiperDataItem[] | undefined): SwiperDataItem[] {
259
259
  return Array.isArray(data) ? data.map((item) => ({ ...item })) : [];
260
260
  }
261
261
 
262
+ function cloneRenderableContent<TContext>(
263
+ content: RenderableContent<TContext>
264
+ ): RenderableContent<TContext> {
265
+ if (typeof Node !== 'undefined' && content instanceof Node) {
266
+ return content.cloneNode(true);
267
+ }
268
+ if (Array.isArray(content)) {
269
+ return content.map((item) => cloneRenderableContent(item));
270
+ }
271
+ return content;
272
+ }
273
+
262
274
  function cloneDataSource(source: SwiperDataSource): SwiperDataSource {
263
275
  return Array.isArray(source) ? cloneData(source) : source;
264
276
  }
@@ -774,7 +786,7 @@ export function createSwiper(input: SwiperProps = {}): Swiper {
774
786
  const realIndex = (): number =>
775
787
  toRealIndexFromTrackPosition(trackIndexAccessor());
776
788
  const slideContent = () => {
777
- const { item } = itemAccessor();
789
+ const { item, clone } = itemAccessor();
778
790
  if (item.children != null) {
779
791
  const context = {
780
792
  swiper,
@@ -783,11 +795,11 @@ export function createSwiper(input: SwiperProps = {}): Swiper {
783
795
  return realIndex();
784
796
  },
785
797
  } as SwiperSlideContext;
786
- return asRenderable(
798
+ const content =
787
799
  typeof item.children === 'function'
788
800
  ? item.children(context)
789
- : item.children
790
- );
801
+ : item.children;
802
+ return asRenderable(clone ? cloneRenderableContent(content) : content);
791
803
  }
792
804
  return [
793
805
  item.image