-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
[swiper element] update function does not process lazy preloaders #6901
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
Comments
@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
Check that this is really a bug
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
Would you like to open a PR for this bug?
The text was updated successfully, but these errors were encountered: