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

uk-slider gets into an infinite loop if there are not <li> takes in a <ul> #5004

Closed
davidebbo opened this issue May 4, 2024 · 0 comments
Closed
Labels
! Bug Something which isn't working as expected

Comments

@davidebbo
Copy link

davidebbo commented May 4, 2024

Here is a complete very minimized repro:

<html>
  <head>
    <script src="https://cdn.jsdelivr.net/npm/uikit@3.20.8/dist/js/uikit.min.js"></script>
  </head>

  <body>
    <div uk-slider="center: true">
      <ul class="uk-slider-items"><!-- issue happens when there are no <li>'s --></ul>
    </div>
  </body>
</html>

It gets into an infinite loop in

while (width > 0) {
const slideIndex = this.getIndex(--j + index, index);
const slide = this.slides[slideIndex];
css(slide, 'order', slideIndex > index ? -2 : -1);
width -= dimensions(slide).width;
}

Basically, slides is an empty list, slide is undefined, and dimensions(slide).width is 0. This causes width to never go down, hence the infinite loop.

In my real app, I have some <li> that are dynamically generated, so the problem happens when the DB data causes the <li> list to be empty.

Relates to OneZoom/OZtree#851

@davidebbo davidebbo added the ! Bug Something which isn't working as expected label May 4, 2024
@davidebbo davidebbo changed the title uk-slide gets into an infinite loop if there are not <li> takes in a <ul> uk-slider gets into an infinite loop if there are not <li> takes in a <ul> May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
! Bug Something which isn't working as expected
Projects
None yet
Development

No branches or pull requests

1 participant