swiper icon indicating copy to clipboard operation
swiper copied to clipboard

swiper.destroy() not working when createElements is enabled

Open samzabala opened this issue 1 year ago • 2 comments

Check that this is really a bug

  • [X] I confirm

Reproduction link

https://codesandbox.io/p/sandbox/swiper-stupid-38lq4g?file=%2Findex.html

Bug description

swiper.destroy() not working when createElements is enabled. wrapperEl is created dynamically when set to true, but destroy breaks scripts and returns fatal error when this is the setup

Error: 0:4290 Uncaught TypeError: Cannot read properties of undefined (reading 'removeAttribute')

Demo: https://codesandbox.io/p/sandbox/swiper-stupid-38lq4g?file=%2Findex.html

Offending line was found ion the destroy method :

wrapperEl.removeAttribute('style');

could be fixed if there is a condition to check if it exists first

if(wrapperEl) wrapperEl.removeAttribute('style');

please help. thank

Expected Behavior

destroy the slider

Actual Behavior

destroys the site

Swiper version

~11.0.5 - 11.1.1 and 11.1.2 checked

Platform/Target and Browser Versions

Chrome/Edie/Webkit Mac OS

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the docs.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • [X] Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • [X] I'm willing to open a PR

samzabala avatar May 13 '24 16:05 samzabala

t0ggles-create swiper

nolimits4web avatar May 13 '24 16:05 nolimits4web

Task nolimits4web/SWIPER-133 was created

t0ggles task SWIPER-133

t0ggles[bot] avatar May 13 '24 16:05 t0ggles[bot]

Task nolimits4web/SWIPER-133 status changed to Done

t0ggles[bot] avatar May 30 '24 09:05 t0ggles[bot]