Skip to content
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
6 changes: 3 additions & 3 deletions __tests__/regression/fix-1813.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ function MultipleItems() {
return <GenericSliderComponent slidesCount={9} settings={settings} />;
}

describe("Multiple Items with slidesToShow = slides count in infinite mode", function() {
it("should have 9 active slides", function() {
describe("Multiple Items with slidesToShow = slides count in infinite mode", function () {
it("should have 9 active slides", function () {
const { container } = render(<MultipleItems />);
expect(getActiveSlidesCount(container)).toEqual(9);
});
it("should show first 9 slides", function() {
it("should show first 9 slides", function () {
const { container } = render(<MultipleItems />);
//expect(getActiveButton(container)).toEqual(["1"]);
expect(getActiveSlidesText(container)).toEqual([
Expand Down
16 changes: 8 additions & 8 deletions __tests__/regression/fix-2414.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,32 @@ function SliderWithUnslick() {
return <GenericSliderComponent slidesCount={2} settings={settings} />;
}

describe("Slider with one slide", function() {
it("should have 1 active slide", function() {
describe("Slider with one slide", function () {
it("should have 1 active slide", function () {
const { container } = render(<SliderWithOneSlide />);
expect(getActiveSlidesCount(container)).toEqual(1);
});
it("should not have any clones", function() {
it("should not have any clones", function () {
const { container } = render(<SliderWithOneSlide />);
expect(getClonesCount(container)).toEqual(0);
});
it("should no have dots and arrows", function() {
it("should no have dots and arrows", function () {
const { container } = render(<SliderWithOneSlide />);
expect(hasArrows(container)).toEqual(false);
expect(hasDots(container)).toEqual(false);
});
});

describe("Slider with unslick=true", function() {
it("should have one active slide", function() {
describe("Slider with unslick=true", function () {
it("should have one active slide", function () {
const { container } = render(<SliderWithUnslick />);
expect(getActiveSlidesCount(container)).toEqual(1);
});
it("should not have any clones", function() {
it("should not have any clones", function () {
const { container } = render(<SliderWithUnslick />);
expect(getClonesCount(container)).toEqual(0);
});
it("should no have dots and arrows", function() {
it("should no have dots and arrows", function () {
const { container } = render(<SliderWithUnslick />);
expect(hasArrows(container)).toEqual(false);
expect(hasDots(container)).toEqual(false);
Expand Down
4 changes: 2 additions & 2 deletions examples/__tests__/MultipleItems.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
} from "../../test-utils";
import MultipleItems from "../MultipleItems";

describe("Multiple Items", function() {
it("should have 9 actual slides and (3(pre) + 3(post)) clone slides", function() {
describe("Multiple Items", function () {
it("should have 9 actual slides and (3(pre) + 3(post)) clone slides", function () {
const { container } = render(<MultipleItems />);
expect(getSlidesCount(container)).toEqual(15);
expect(getClonesCount(container)).toEqual(6);
Expand Down
2 changes: 1 addition & 1 deletion examples/__tests__/SimpleSlider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "../../test-utils";

describe("SimpleSlider example", () => {
it("should have 13 slides (1(preclone) + 6(actual) + 1(postclone))", function() {
it("should have 13 slides (1(preclone) + 6(actual) + 1(postclone))", function () {
const { container } = render(<SimpleSlider />);
expect(container.getElementsByClassName("slick-slide").length).toBe(8);
});
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gulp.task("copy", function () {
.pipe(gulp.dest("./build"));
});

gulp.task("prepare-playwright", function() {
gulp.task("prepare-playwright", function () {
// Copy files to src-jsx directory with jsx extension
return gulp
.src("./src/**/*.js")
Expand Down
6 changes: 2 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
module.exports = {
collectCoverage: true,
coverageReporters: ['text', 'cobertura'],
collectCoverageFrom: [
'src/**/*',
],
coverageReporters: ["text", "cobertura"],
collectCoverageFrom: ["src/**/*"],
testEnvironment: "jsdom",
setupFilesAfterEnv: ["<rootDir>/test-setup.js"],
testPathIgnorePatterns: ["/node_modules/", "playwright-tests"],
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.7",
"clsx": "^2.1.1",
"@testing-library/dom": "^10.4.1",
"classnames": "^2.2.5",
"json2mq": "^0.2.0",
"resize-observer-polyfill": "^1.5.1",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Removing resize-observer-polyfill is a significant change that could affect users on browsers without native ResizeObserver support. This should be clearly communicated as a potential breaking change. Please consider updating the pull request title and adding a description that explains the impact of this removal.

"throttle-debounce": "^5.0.0"
},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/arrows.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

import React from "react";
import classnames from "classnames";
import { clsx } from "clsx";
import { canGoNext } from "./utils/innerSliderUtils";

export class PrevArrow extends React.PureComponent {
Expand All @@ -27,7 +27,7 @@ export class PrevArrow extends React.PureComponent {
let prevArrowProps = {
key: "0",
"data-role": "none",
className: classnames(prevClasses),
className: clsx(prevClasses),
style: { display: "block" },
onClick: prevHandler
};
Expand Down Expand Up @@ -74,7 +74,7 @@ export class NextArrow extends React.PureComponent {
let nextArrowProps = {
key: "1",
"data-role": "none",
className: classnames(nextClasses),
className: clsx(nextClasses),
style: { display: "block" },
onClick: nextHandler
};
Expand Down
6 changes: 3 additions & 3 deletions src/dots.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";

import React from "react";
import classnames from "classnames";
import { clsx } from "clsx";
import { clamp } from "./utils/innerSliderUtils";

const getDotCount = spec => {
const getDotCount = (spec) => {
let dots;

if (spec.infinite) {
Expand Down Expand Up @@ -55,7 +55,7 @@ export class Dots extends React.PureComponent {
? _leftBound
: clamp(_leftBound, 0, slideCount - 1);

let className = classnames({
let className = clsx({
"slick-active": infinite
? currentSlide >= leftBound && currentSlide <= rightBound
: currentSlide === leftBound
Expand Down
31 changes: 16 additions & 15 deletions src/inner-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from "react";
import initialState from "./initial-state";
import { debounce } from "throttle-debounce";
import classnames from "classnames";
import { clsx } from "clsx";
import {
getOnDemandLazySlides,
extractObject,
Expand All @@ -25,7 +25,6 @@ import {
import { Track } from "./track";
import { Dots } from "./dots";
import { PrevArrow, NextArrow } from "./arrows";
import ResizeObserver from "resize-observer-polyfill";
Comment thread
yoyo837 marked this conversation as resolved.

export class InnerSlider extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -78,17 +77,19 @@ export class InnerSlider extends React.Component {
if (this.props.lazyLoad === "progressive") {
this.lazyLoadTimer = setInterval(this.progressiveLazyLoad, 1000);
}
this.ro = new ResizeObserver(() => {
if (this.state.animating) {
this.onWindowResized(false); // don't set trackStyle hence don't break animation
this.callbackTimers.push(
setTimeout(() => this.onWindowResized(), this.props.speed)
);
} else {
this.onWindowResized();
}
});
this.ro.observe(this.list);
if (typeof ResizeObserver !== "undefined") {
this.ro = new ResizeObserver(() => {
if (this.state.animating) {
this.onWindowResized(false); // don't set trackStyle hence don't break animation
this.callbackTimers.push(
setTimeout(() => this.onWindowResized(), this.props.speed)
);
} else {
this.onWindowResized();
}
});
this.ro.observe(this.list);
}
document.querySelectorAll &&
Array.prototype.forEach.call(
document.querySelectorAll(".slick-slide"),
Expand Down Expand Up @@ -122,7 +123,7 @@ export class InnerSlider extends React.Component {
if (this.autoplayTimer) {
clearInterval(this.autoplayTimer);
}
this.ro.disconnect();
this.ro?.disconnect();
};

didPropsChange(prevProps) {
Expand Down Expand Up @@ -619,7 +620,7 @@ export class InnerSlider extends React.Component {
this.autoPlay("blur");

render = () => {
var className = classnames("slick-slider", this.props.className, {
var className = clsx("slick-slider", this.props.className, {
"slick-vertical": this.props.vertical,
"slick-initialized": true
});
Expand Down
10 changes: 5 additions & 5 deletions src/track.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

import React from "react";
import classnames from "classnames";
import { clsx } from "clsx";
import {
lazyStartIndex,
lazyEndIndex,
Expand Down Expand Up @@ -123,7 +123,7 @@ const renderSlides = (spec) => {
React.cloneElement(child, {
key: "original" + getKey(child, index),
"data-index": index,
className: classnames(slideClasses, slideClass),
className: clsx(slideClasses, slideClass),
tabIndex: "-1",
"aria-hidden": !slideClasses["slick-active"],
style: { outline: "none", ...(child.props.style || {}), ...childStyle },
Expand Down Expand Up @@ -155,7 +155,7 @@ const renderSlides = (spec) => {
key: "precloned" + getKey(child, key),
"data-index": key,
tabIndex: "-1",
className: classnames(slideClasses, slideClass),
className: clsx(slideClasses, slideClass),
"aria-hidden": !slideClasses["slick-active"],
style: { ...(child.props.style || {}), ...childStyle },
onClick: (e) => {
Expand All @@ -178,10 +178,10 @@ const renderSlides = (spec) => {
key: "postcloned" + getKey(child, key),
"data-index": key,
tabIndex: "-1",
className: classnames(slideClasses, slideClass),
className: clsx(slideClasses, slideClass),
"aria-hidden": !slideClasses["slick-active"],
style: { ...(child.props.style || {}), ...childStyle },
onClick: e => {
onClick: (e) => {
child.props && child.props.onClick && child.props.onClick(e);
if (spec.focusOnSelect) {
spec.focusOnSelect(childOnClickOptions);
Expand Down