@@ -4,7 +4,7 @@ import { App } from '../app/app';
4
4
import { Config } from '../../config/config' ;
5
5
import { DeepLinker } from '../../navigation/deep-linker' ;
6
6
import { Ion } from '../ion' ;
7
- import { isBlank } from '../../util/util' ;
7
+ import { isBlank , assert } from '../../util/util' ;
8
8
import { NavController } from '../../navigation/nav-controller' ;
9
9
import { NavControllerBase } from '../../navigation/nav-controller-base' ;
10
10
import { getComponent , NavOptions , DIRECTION_SWITCH } from '../../navigation/nav-util' ;
@@ -408,14 +408,24 @@ export class Tabs extends Ion implements AfterViewInit {
408
408
if ( opts . updateUrl !== false ) {
409
409
this . _linker . navChange ( DIRECTION_SWITCH ) ;
410
410
}
411
+ this . _fireChangeEvent ( selectedTab ) ;
411
412
} ) ;
413
+ } else {
414
+ this . _fireChangeEvent ( selectedTab ) ;
412
415
}
416
+ }
417
+
418
+ _fireChangeEvent ( selectedTab : Tab ) {
419
+ assert ( this . getSelected ( ) === selectedTab , 'selected tab does not match' ) ;
413
420
414
421
selectedTab . ionSelect . emit ( selectedTab ) ;
415
422
this . ionChange . emit ( selectedTab ) ;
416
423
}
417
424
418
425
_tabSwitchEnd ( selectedTab : Tab , selectedPage : ViewController , currentPage : ViewController ) {
426
+ assert ( selectedTab , 'selectedTab must be valid' ) ;
427
+ assert ( this . _tabs . indexOf ( selectedTab ) >= 0 , 'selectedTab must be one of the tabs' ) ;
428
+
419
429
// Update tabs selection state
420
430
const tabs = this . _tabs ;
421
431
let tab : Tab ;
@@ -473,9 +483,10 @@ export class Tabs extends Ion implements AfterViewInit {
473
483
* @return {Tab } Returns the currently selected tab
474
484
*/
475
485
getSelected ( ) : Tab {
476
- for ( var i = 0 ; i < this . _tabs . length ; i ++ ) {
477
- if ( this . _tabs [ i ] . isSelected ) {
478
- return this . _tabs [ i ] ;
486
+ const tabs = this . _tabs ;
487
+ for ( var i = 0 ; i < tabs . length ; i ++ ) {
488
+ if ( tabs [ i ] . isSelected ) {
489
+ return tabs [ i ] ;
479
490
}
480
491
}
481
492
return null ;
0 commit comments