Ionic-framework: Swiper Error Cannot read property 'length' of undefined

Created on 1 Sep 2017  Â·  4Comments  Â·  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[x] 3.x

I'm submitting a ... (check one with "x")
[x] bug report

Current behavior:
Updating the data in an ion-list that contains an ion-slides causes a console error.

ERROR TypeError: Cannot read property 'length' of undefined
    at destroyLoop (swiper.ts:696)
    at Object.destroySwiper (swiper.ts:1002)
    at Slides.ngOnDestroy (slides.ts:1162)
    at callProviderLifecycles (query.ts:1)
    at callElementProvidersLifecycles (provider.ts:619)
    at callLifecycleHooksChildrenFirst (provider.ts:603)
    at destroyView (view.ts:642)
    at callWithDebugContext (services.ts:815)
    at Object.debugDestroyView [as destroyView] (services.ts:404)
    at ViewContainerRef_.remove (refs.ts:357)

Expected behavior:

Updating the data should not cause errors.

Steps to reproduce:

http://embed.plnkr.co/9RfxERbAm9PvR9DvJ5PJ/

Double click the update button and the error above will log to the console

Related code:
See Plnkr

Other information:

This could be fixed by testing for s._slides in ionic/src/components/slides/swiper/swiper.ts

function destroyLoop(s: Slides) {
  eachChild(s._wrapper, '.' + CLS.slide + '.' + CLS.slideDuplicate, ele => {
    ele.parentElement.removeChild(ele);
  });
  if (s._slides) {
    for (var i = 0; i < s._slides.length; i++) {
      s._slides[i].removeAttribute('data-swiper-slide-index');
    }
  }
}

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Most helpful comment

Hello! Thank you for opening an issue with us!

A fix for this has been committed and will be in the next 3.6.x release.

Thank you for using Ionic

All 4 comments

Hello! Thank you for opening an issue with us!

A fix for this has been committed and will be in the next 3.6.x release.

Thank you for using Ionic

We have created an ionic-angular@nightly with the fix for this issue included in preparation for a new release. I have tested it via the sample repo and it works for that particular case. If you would like to try this in your app you can use npm install ionic-angular@nightly

Excellent thank you

On 7 Sep. 2017 5:36 am, "Ken Sodemann" notifications@github.com wrote:

We have created an ionic-angular@nightly with the fix for this issue
included in preparation for a new release. I have tested it via the sample
repo and it works for that particular case. If you would like to try this
in your app you can use npm install ionic-angular@nightly

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/ionic-team/ionic/issues/12791#issuecomment-327590489,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAFR39Rk7o3XAabz3b7GBNbkCzEJf1xsks5sfvQwgaJpZM4PJiXg
.

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nick-The-Uncharted picture Nick-The-Uncharted  Â·  3Comments

alan-agius4 picture alan-agius4  Â·  3Comments

MrBokeh picture MrBokeh  Â·  3Comments

GeorgeAnanthSoosai picture GeorgeAnanthSoosai  Â·  3Comments

brandyscarney picture brandyscarney  Â·  3Comments