@@ -286,16 +286,17 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
286
286
* @author Naotoshi Fujita
287
287
* @copyright Naotoshi Fujita. All rights reserved.
288
288
*/
289
-
289
+ var keys = Object . keys ;
290
290
/**
291
291
* Iterate an object like Array.forEach.
292
292
* IE doesn't support forEach of HTMLCollection.
293
293
*
294
294
* @param {Object } obj - An object.
295
295
* @param {function } callback - A function handling each value. Arguments are value, property and index.
296
296
*/
297
+
297
298
function each ( obj , callback ) {
298
- Object . keys ( obj ) . some ( function ( key , index ) {
299
+ keys ( obj ) . some ( function ( key , index ) {
299
300
return callback ( obj [ key ] , key , index ) ;
300
301
} ) ;
301
302
}
@@ -309,7 +310,7 @@ function each(obj, callback) {
309
310
*/
310
311
311
312
function values ( obj ) {
312
- return Object . keys ( obj ) . map ( function ( key ) {
313
+ return keys ( obj ) . map ( function ( key ) {
313
314
return obj [ key ] ;
314
315
} ) ;
315
316
}
@@ -360,7 +361,7 @@ function merge(_ref, from) {
360
361
361
362
function object_assign ( to , from ) {
362
363
to . _s = from ;
363
- Object . keys ( from ) . forEach ( function ( key ) {
364
+ keys ( from ) . forEach ( function ( key ) {
364
365
if ( ! to [ key ] ) {
365
366
Object . defineProperty ( to , key , Object . getOwnPropertyDescriptor ( from , key ) ) ;
366
367
}
@@ -501,7 +502,7 @@ function find(elm, selector) {
501
502
function child ( parent , tagOrClassName ) {
502
503
if ( parent ) {
503
504
return values ( parent . children ) . filter ( function ( child ) {
504
- return hasClass ( child , tagOrClassName . split ( ' ' ) [ 0 ] ) || child . tagName . toLowerCase ( ) === tagOrClassName ;
505
+ return hasClass ( child , tagOrClassName . split ( ' ' ) [ 0 ] ) || child . tagName === tagOrClassName ;
505
506
} ) [ 0 ] || null ;
506
507
}
507
508
@@ -544,8 +545,9 @@ function domify(html) {
544
545
545
546
function dom_remove ( elms ) {
546
547
toArray ( elms ) . forEach ( function ( elm ) {
547
- if ( elm && elm . parentElement ) {
548
- elm . parentElement . removeChild ( elm ) ;
548
+ if ( elm ) {
549
+ var parent = elm . parentElement ;
550
+ parent && parent . removeChild ( elm ) ;
549
551
}
550
552
} ) ;
551
553
}
@@ -569,8 +571,9 @@ function append(parent, child) {
569
571
*/
570
572
571
573
function before ( elm , ref ) {
572
- if ( elm && ref && ref . parentElement ) {
573
- ref . parentElement . insertBefore ( elm , ref ) ;
574
+ if ( elm && ref ) {
575
+ var parent = ref . parentElement ;
576
+ parent && parent . insertBefore ( elm , ref ) ;
574
577
}
575
578
}
576
579
/**
@@ -1987,7 +1990,7 @@ var STYLE_RESTORE_EVENTS = 'update.slide';
1987
1990
*
1988
1991
* @type {Element|null }
1989
1992
*/
1990
- container : find ( slide , "." + Splide . classes . container ) ,
1993
+ container : child ( slide , Splide . classes . container ) ,
1991
1994
1992
1995
/**
1993
1996
* Whether this is a cloned slide or not.
@@ -2017,8 +2020,8 @@ var STYLE_RESTORE_EVENTS = 'update.slide';
2017
2020
*/
2018
2021
2019
2022
if ( updateOnMove ) {
2020
- Splide . on ( 'move.slide' , function ( ) {
2021
- if ( Splide . index === realIndex ) {
2023
+ Splide . on ( 'move.slide' , function ( newIndex ) {
2024
+ if ( newIndex === realIndex ) {
2022
2025
_update ( true , false ) ;
2023
2026
}
2024
2027
} ) ;
@@ -2214,8 +2217,7 @@ var UID_NAME = 'uid';
2214
2217
_this . destroy ( ) ;
2215
2218
2216
2219
_this . init ( ) ;
2217
- } ) ;
2218
- Splide . on ( 'updated' , function ( ) {
2220
+ } ) . on ( 'updated' , function ( ) {
2219
2221
removeClass ( root , getClasses ( ) ) ;
2220
2222
addClass ( root , getClasses ( ) ) ;
2221
2223
} ) ;
@@ -2311,7 +2313,7 @@ var UID_NAME = 'uid';
2311
2313
}
2312
2314
2313
2315
if ( slide instanceof Element ) {
2314
- var ref = this . slides [ index ] ; // This will be removed in mount() of Slide component.
2316
+ var ref = this . slides [ index ] ; // This will be removed in mount() of a Slide component.
2315
2317
2316
2318
applyStyle ( slide , {
2317
2319
display : 'none'
@@ -3176,6 +3178,13 @@ var controller_floor = Math.floor;
3176
3178
* @type {Array }
3177
3179
*/
3178
3180
var clones = [ ] ;
3181
+ /**
3182
+ * Store the current clone count on one side.
3183
+ *
3184
+ * @type {number }
3185
+ */
3186
+
3187
+ var cloneCount = 0 ;
3179
3188
/**
3180
3189
* Keep Elements component.
3181
3190
*
@@ -3194,14 +3203,12 @@ var controller_floor = Math.floor;
3194
3203
* Called when the component is mounted.
3195
3204
*/
3196
3205
mount : function mount ( ) {
3197
- var _this = this ;
3198
-
3199
3206
if ( Splide . is ( LOOP ) ) {
3200
- generateClones ( ) ;
3201
- Splide . on ( 'refresh' , function ( ) {
3202
- _this . destroy ( ) ;
3203
-
3204
- generateClones ( ) ;
3207
+ init ( ) ;
3208
+ Splide . on ( 'refresh' , init ) . on ( 'resize' , function ( ) {
3209
+ if ( cloneCount !== getCloneCount ( ) ) {
3210
+ Splide . refresh ( ) ;
3211
+ }
3205
3212
} ) ;
3206
3213
}
3207
3214
} ,
@@ -3233,18 +3240,29 @@ var controller_floor = Math.floor;
3233
3240
}
3234
3241
3235
3242
} ;
3243
+ /**
3244
+ * Initialization.
3245
+ */
3246
+
3247
+ function init ( ) {
3248
+ Clones . destroy ( ) ;
3249
+ cloneCount = getCloneCount ( ) ;
3250
+ generateClones ( cloneCount ) ;
3251
+ }
3236
3252
/**
3237
3253
* Generate and append/prepend clones.
3254
+ *
3255
+ * @param {number } count - The half number of clones.
3238
3256
*/
3239
3257
3240
- function generateClones ( ) {
3258
+
3259
+ function generateClones ( count ) {
3241
3260
var length = Elements . length ;
3242
3261
3243
3262
if ( ! length ) {
3244
3263
return ;
3245
3264
}
3246
3265
3247
- var count = getCloneCount ( ) ;
3248
3266
var slides = Elements . slides ;
3249
3267
3250
3268
while ( slides . length < count ) {
@@ -3283,15 +3301,15 @@ var controller_floor = Math.floor;
3283
3301
3284
3302
if ( options . clones ) {
3285
3303
return options . clones ;
3286
- } // Use the slide length in autoWidth mode because the number candnot be calculated.
3304
+ } // Use the slide length in autoWidth mode because the number cannot be calculated.
3287
3305
3288
3306
3289
3307
var baseCount = options . autoWidth ? Elements . length : options . perPage ;
3290
3308
var dimension = options . direction === TTB ? 'Height' : 'Width' ;
3291
3309
var fixedSize = options [ "fixed" + dimension ] ;
3292
3310
3293
3311
if ( fixedSize ) {
3294
- // Roughly determine the count. This needs not to be strict.
3312
+ // Roughly calculate the count. This needs not to be strict.
3295
3313
baseCount = Math . ceil ( Elements . track [ "client" + dimension ] / fixedSize ) ;
3296
3314
}
3297
3315
@@ -4442,7 +4460,7 @@ var PAUSE_FLAGS = {
4442
4460
4443
4461
function apply ( uncover ) {
4444
4462
Components . Elements . each ( function ( Slide ) {
4445
- var img = child ( Slide . slide , 'img ' ) || child ( Slide . container , 'img ' ) ;
4463
+ var img = child ( Slide . slide , 'IMG ' ) || child ( Slide . container , 'IMG ' ) ;
4446
4464
4447
4465
if ( img && img . src ) {
4448
4466
cover ( img , uncover ) ;
@@ -5220,6 +5238,13 @@ var TAB_INDEX = 'tabindex';
5220
5238
*/
5221
5239
5222
5240
var Elements = Components . Elements ;
5241
+ /**
5242
+ * All attributes related with A11y.
5243
+ *
5244
+ * @type {string[] }
5245
+ */
5246
+
5247
+ var allAttributes = [ ARIA_HIDDEN , TAB_INDEX , ARIA_CONTROLS , ARIA_LABEL , ARIA_CURRENRT , 'role' ] ;
5223
5248
/**
5224
5249
* A11y component object.
5225
5250
*
@@ -5242,7 +5267,9 @@ var TAB_INDEX = 'tabindex';
5242
5267
updateSlide ( Slide . slide , true ) ;
5243
5268
} ) . on ( 'hidden' , function ( Slide ) {
5244
5269
updateSlide ( Slide . slide , false ) ;
5245
- } ) . on ( 'arrows:mounted' , initArrows ) . on ( 'arrows:updated' , updateArrows ) . on ( 'pagination:mounted' , initPagination ) . on ( 'pagination:updated' , updatePagination ) ;
5270
+ } ) . on ( 'arrows:mounted' , initArrows ) . on ( 'arrows:updated' , updateArrows ) . on ( 'pagination:mounted' , initPagination ) . on ( 'pagination:updated' , updatePagination ) . on ( 'refresh' , function ( ) {
5271
+ removeAttribute ( Components . Clones . clones , allAttributes ) ;
5272
+ } ) ;
5246
5273
5247
5274
if ( Splide . options . isNavigation ) {
5248
5275
Splide . on ( 'navigation:mounted' , initNavigation ) . on ( 'active' , function ( Slide ) {
@@ -5259,8 +5286,9 @@ var TAB_INDEX = 'tabindex';
5259
5286
* Destroy.
5260
5287
*/
5261
5288
destroy : function destroy ( ) {
5262
- var arrows = Components . Arrows ? Components . Arrows . arrows : { } ;
5263
- removeAttribute ( Elements . slides . concat ( [ arrows . prev , arrows . next , Elements . play , Elements . pause ] ) , [ ARIA_HIDDEN , TAB_INDEX , ARIA_CONTROLS , ARIA_LABEL , ARIA_CURRENRT , 'role' ] ) ;
5289
+ var Arrows = Components . Arrows ;
5290
+ var arrows = Arrows ? Arrows . arrows : { } ;
5291
+ removeAttribute ( Elements . slides . concat ( [ arrows . prev , arrows . next , Elements . play , Elements . pause ] ) , allAttributes ) ;
5264
5292
}
5265
5293
} ;
5266
5294
/**
@@ -5377,16 +5405,15 @@ var TAB_INDEX = 'tabindex';
5377
5405
5378
5406
5379
5407
function initNavigation ( main ) {
5380
- Elements . each ( function ( _ref ) {
5381
- var slide = _ref . slide ,
5382
- realIndex = _ref . realIndex ,
5383
- index = _ref . index ;
5408
+ Elements . each ( function ( Slide ) {
5409
+ var slide = Slide . slide ;
5410
+ var realIndex = Slide . realIndex ;
5384
5411
5385
5412
if ( ! isButton ( slide ) ) {
5386
5413
setAttribute ( slide , 'role' , 'button' ) ;
5387
5414
}
5388
5415
5389
- var slideIndex = realIndex > - 1 ? realIndex : index ;
5416
+ var slideIndex = realIndex > - 1 ? realIndex : Slide . index ;
5390
5417
var label = sprintf ( i18n . slideX , slideIndex + 1 ) ;
5391
5418
var mainSlide = main . Components . Elements . getSlide ( slideIndex ) ;
5392
5419
setAttribute ( slide , ARIA_LABEL , label ) ;
@@ -5404,8 +5431,8 @@ var TAB_INDEX = 'tabindex';
5404
5431
*/
5405
5432
5406
5433
5407
- function updateNavigation ( _ref2 , active ) {
5408
- var slide = _ref2 . slide ;
5434
+ function updateNavigation ( _ref , active ) {
5435
+ var slide = _ref . slide ;
5409
5436
5410
5437
if ( active ) {
5411
5438
setAttribute ( slide , ARIA_CURRENRT , true ) ;
@@ -5423,7 +5450,7 @@ var TAB_INDEX = 'tabindex';
5423
5450
5424
5451
5425
5452
function isButton ( elm ) {
5426
- return elm . tagName . toLowerCase ( ) === 'button ' ;
5453
+ return elm . tagName === 'BUTTON ' ;
5427
5454
}
5428
5455
5429
5456
return A11y ;
0 commit comments