Sfoglia il codice sorgente

Avoid overriding the `aria-label` if a slide already has.

NaotoshiFujita 3 anni fa
parent
commit
951adea6b3

+ 3 - 1
dist/js/splide.js

@@ -867,6 +867,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
         pagination = options.pagination;
     var resolve = Components.Direction.resolve;
     var styles = getAttribute(slide, "style");
+    var label = getAttribute(slide, ARIA_LABEL);
     var isClone = slideIndex > -1;
     var container = child(slide, "." + CLASS_CONTAINER);
     var destroyed;
@@ -876,7 +877,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
         slide.id = root.id + "-slide" + pad(index + 1);
         setAttribute(slide, ROLE, pagination ? "tabpanel" : "group");
         setAttribute(slide, ARIA_ROLEDESCRIPTION, pagination ? "" : i18n.slide);
-        setAttribute(slide, ARIA_LABEL, format(i18n.slideLabel, [index + 1, Splide2.length]));
+        setAttribute(slide, ARIA_LABEL, label || format(i18n.slideLabel, [index + 1, Splide2.length]));
       }
 
       listen();
@@ -900,6 +901,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
       removeClass(slide, STATUS_CLASSES);
       removeAttribute(slide, ALL_ATTRIBUTES);
       setAttribute(slide, "style", styles);
+      setAttribute(slide, ARIA_LABEL, label || "");
     }
 
     function initNavigation() {

File diff suppressed because it is too large
+ 0 - 0
dist/js/splide.min.js


BIN
dist/js/splide.min.js.gz


File diff suppressed because it is too large
+ 0 - 0
dist/js/splide.min.js.map


+ 3 - 1
src/js/components/Slides/Slide.ts

@@ -91,6 +91,7 @@ export function Slide( Splide: Splide, index: number, slideIndex: number, slide:
   const { isNavigation, updateOnMove, i18n, pagination } = options;
   const { resolve } = Components.Direction;
   const styles    = getAttribute( slide, 'style' );
+  const label     = getAttribute( slide, ARIA_LABEL );
   const isClone   = slideIndex > -1;
   const container = child( slide, `.${ CLASS_CONTAINER }` );
 
@@ -107,7 +108,7 @@ export function Slide( Splide: Splide, index: number, slideIndex: number, slide:
       slide.id = `${ root.id }-slide${ pad( index + 1 ) }`;
       setAttribute( slide, ROLE, pagination ? 'tabpanel' : 'group' );
       setAttribute( slide, ARIA_ROLEDESCRIPTION, pagination ? '' : i18n.slide );
-      setAttribute( slide, ARIA_LABEL, format( i18n.slideLabel, [ index + 1, Splide.length ] ) );
+      setAttribute( slide, ARIA_LABEL, label || format( i18n.slideLabel, [ index + 1, Splide.length ] ) );
     }
 
     listen();
@@ -137,6 +138,7 @@ export function Slide( Splide: Splide, index: number, slideIndex: number, slide:
     removeClass( slide, STATUS_CLASSES );
     removeAttribute( slide, ALL_ATTRIBUTES );
     setAttribute( slide, 'style', styles );
+    setAttribute( slide, ARIA_LABEL, label || '' );
   }
 
   /**

+ 4 - 1
src/js/test/php/examples/default.php

@@ -37,7 +37,10 @@ $settings = get_settings();
 						direction: 'ttb',
 						height   : 500,
 						perPage  : 2,
-					}
+					},
+		      1000: {
+						destroy: true,
+		      }
 	      }
       } );
 

Some files were not shown because too many files changed in this diff