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

Undefined method slice when clicking on a specific slider bullet. #371

Open
tylercrocker opened this issue Jun 13, 2019 · 5 comments
Open

Comments

@tylercrocker
Copy link

tylercrocker commented Jun 13, 2019

I'm seeing the following error when clicking on individual slider bullet:

glide.esm.js:2046 Uncaught TypeError: Cannot read property 'slice' of null

This is because the event bubbles up to the slider parent during the following event handler (glide.esm.js:3242):

click: function click(event) {
  event.preventDefault();

  Components.Run.make(Components.Direction.resolve(event.currentTarget.getAttribute('data-glide-dir')));
}

event.currentTarget.getAttribute('data-glide-dir') returns nothing, since event.currentTarget doesn't have that attribute, and then the resolve method at glide.esm.js:2045 immediately attempts to call slice(0, 1) on the null object it was passed, and therefore breaks.

While the overarching click event DOES WORK, having this JS error happen is rather silly. Could we have the resolve function verify that it does indeed have something before trying to call slice, the initial offending click event not call resolve if it would pass it nothing, or have the click event not bubble?

Thanks!

(P.S. - I'm more than happy to open a PR for this, I just am not super familiar with the codebase and don't want to make any assumptions about your best practices!)

@atmonello
Copy link

Getting this error too, when trying to call disabled().

@atmonello
Copy link

Getting this error too, when trying to call disabled().

Nevermind, it was because I was clicking a button I have included inside the .glide__arrows container, so it was trying to find the same data-glide-dir on my custom button (which didn't have that attribute).

Maybe it can give you any tips, @tylercrocker

@Heet1996
Copy link

Heet1996 commented Dec 15, 2020

@tylercrocker I am facing the same issue. Can you please share your solution?

@juanpablob
Copy link

I'm getting this error too :/

@Shaidulint
Copy link

Shaidulint commented Aug 4, 2022

I figured out the reason for my case:
it was because I inserted bullets data-glide-el="controls[nav]" into data-glide-el="controls"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants