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

Cannot read property 'toString' of null if data-history attribute is missing when using Thumbs+Gallery+Loop #4384

Closed
Sebastian-Habiger opened this issue Mar 29, 2021 · 5 comments

Comments

@Sebastian-Habiger
Copy link

Sebastian-Habiger commented Mar 29, 2021

Hi,

it seems like history navigation is now enabled and cannot be disabled, therefore if the data-history attribute is missing a Javascript error is thrown.
Manually setting the history option to false didn't do anything.

Uncaught TypeError: Cannot read property 'toString' of null
at Object.slugify (history.js:79)
at t.scrollToSlide (history.js:91)
at t.init (history.js:18)
at t.init (history.js:123)
at events-emitter.js:95
at Array.forEach ()
at events-emitter.js:94
at Array.forEach ()
at t.emit (events-emitter.js:87)
at t.r.init (core-class.js:499)

Downgrading to 6.4.15 worked for me. As I did not check version 6.5.0, I am not sure in which of these two Versions this bug was introduced.

Hope this helps to find the Bug.

Maybe something like

history.js(91)
const slideHistory = History.slugify(slide.attr('data-history') || '');

will fix that error.

@nolimits4web
Copy link
Owner

Example? Demo? Core, Vue, React, Svelte, Angular?

@Sebastian-Habiger
Copy link
Author

Sebastian-Habiger commented Mar 29, 2021

Good Question,

actually, I do not know I used the Version from cdn.

https://unpkg.com/swiper/swiper-bundle.min.js

Actually, this bug only applies to Thumbs Gallery Loop
As a demo, you can use your own ones from your documentation
https://swiperjs.com/demos#thumbs-gallery-loop
https://codesandbox.io/s/2qkt9

Hope this helps

While debugging I found that line 91 inside history.js was always called, which has to fail as I did not have data-history attributes set. After setting these attributes the history was updated, which for my understanding of history:false should not happen.
const slideHistory = History.slugify(slide.attr('data-history'));

@Sebastian-Habiger Sebastian-Habiger changed the title Cannot read property 'toString' of null if data-history attribute is missing Cannot read property 'toString' of null if data-history attribute is missing when using Thumbs+Gallery+Loop Mar 29, 2021
@ghost
Copy link

ghost commented Mar 29, 2021

Does not work Thumbs Gallery. https://swiperjs.com/demos/300-thumbs-gallery.html

@smernick
Copy link

We are also seeing this issue when linking our Thumb slider with our main slider. It is completely broken and also broken on the swiper.js demo site. Is there any plan to fix this or set back the version to before this bug was introduced?

@JulianSamarjiev
Copy link

JulianSamarjiev commented Mar 29, 2021

I'm still seeing the issue - https://swiperjs.com/demos#thumbs-gallery (here is a demo, regarding the "missing demo" tag)

Repository owner locked and limited conversation to collaborators Mar 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants