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

[swiper element] update function does not process lazy preloaders #6901

Closed
6 tasks done
bmandl opened this issue Aug 3, 2023 · 1 comment · May be fixed by abhishekbedi/framework7#1, Aarod23/nys-site#1 or wierza/Team-project#148
Closed
6 tasks done

Comments

@bmandl
Copy link

bmandl commented Aug 3, 2023

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/sandbox/swiper-lazy-load-images-forked-2jn2dr?file=%2Findex.html%3A1%2C1

Bug description

When using swiper element with init="false" attribute, if swiper initialization is postponed, so that images are loaded before swiper initialization, lazyPreloader won't get processed inside swiper-slide elements.
Bug probably lies in lines 3479 - 3487 in the file swiper-core.mjs:
[...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => { if (imageEl.complete) { processLazyPreloader(swiper, imageEl); } else { imageEl.addEventListener('load', e => { processLazyPreloader(swiper, e.target); }); } });

querySelectorAll is ran against swiper.el element, which is shadow dom element in case of swiper element. querySelectorAll can't find any '[loading="lazy"]' elements, because these are put inside swiper-slide elements, which are slotted inside shadow dom of swiper-container.

Expected Behavior

Swiper lazy preloader should be removed from swiper-slide elements with parameter lazy="true"

Actual Behavior

Swiper lazy preloader is not removed from swiper-slide elements with parameter lazy="true"

Swiper version

10.1.0

Platform/Target and Browser Versions

Windows 10, Chrome, Brave, Firefox

Validations

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

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@bmandl
Copy link
Author

bmandl commented Aug 8, 2023

@nolimits4web did you commit on the wrong branch maybe? Why is 10.0.4 latest release, instead of 10.1.0?

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