Undefined method slice when clicking on a specific slider bullet.
See original GitHub issueI’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:
- Created 4 years ago
- Reactions:2
- Comments:5
I figured out the reason for my case: it was because I inserted bullets
data-glide-el="controls[nav]"
intodata-glide-el="controls"
I’m getting this error too 😕