question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Undefined method slice when clicking on a specific slider bullet.

See original GitHub issue

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!)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
Shaidulintcommented, 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"

0reactions
juanpablobcommented, May 12, 2021

I’m getting this error too 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Undefined method 'slice' - ruby on rails - Stack Overflow
It's an object that behaves (partially) like a Hash. There is no slice method on it. It's unclear what you're trying to accomplish...
Read more >
Success message not working - WordPress.org
Hello guys,. ive got problem with CF7. After clicking send button there is no any notoficiation that message has been sent.
Read more >
Solved: HELP With JS Flickity carousel - Experts Exchange
I am using http://flickity.metafizzy.co for my carousel and I am trying to make the cells images but can't figure out how to remove...
Read more >
Swiper Changelog
a11y: fix JS error "swiper.a11y is undefined" (#6226) (02c1502) ... a11y: don't focus slide on slide inner elements clicks (c8e22f7), closes #6116 ...
Read more >
REDCap Change Log - Eastern Virginia Medical School
slider setting is not checked/enabled. (Ticket #131065); Bug fix: When using one of the "X & Table-based" authentication methods, various processes (e.g., ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found