wp/wp-includes/js/jquery/ui/accordion.js
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-includes/js/jquery/ui/accordion.js	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/js/jquery/ui/accordion.js	Tue Sep 27 16:37:53 2022 +0200
@@ -1,5 +1,5 @@
 /*!
- * jQuery UI Accordion 1.12.1
+ * jQuery UI Accordion 1.13.1
  * http://jqueryui.com
  *
  * Copyright jQuery Foundation and other contributors
@@ -9,9 +9,9 @@
 
 //>>label: Accordion
 //>>group: Widgets
-// jscs:disable maximumLineLength
+/* eslint-disable max-len */
 //>>description: Displays collapsible content panels for presenting information in a limited amount of space.
-// jscs:enable maximumLineLength
+/* eslint-enable max-len */
 //>>docs: http://api.jqueryui.com/accordion/
 //>>demos: http://jqueryui.com/accordion/
 //>>css.structure: ../../themes/base/core.css
@@ -19,6 +19,8 @@
 //>>css.theme: ../../themes/base/theme.css
 
 ( function( factory ) {
+	"use strict";
+
 	if ( typeof define === "function" && define.amd ) {
 
 		// AMD. Register as an anonymous module.
@@ -31,10 +33,11 @@
 		// Browser globals
 		factory( jQuery );
 	}
-}( function( $ ) {
+} )( function( $ ) {
+"use strict";
 
 return $.widget( "ui.accordion", {
-	version: "1.12.1",
+	version: "1.13.1",
 	options: {
 		active: 0,
 		animate: {},
@@ -45,7 +48,9 @@
 		},
 		collapsible: false,
 		event: "click",
-		header: "> li > :first-child, > :not(li):even",
+		header: function( elem ) {
+			return elem.find( "> li > :first-child" ).add( elem.find( "> :not(li)" ).even() );
+		},
 		heightStyle: "auto",
 		icons: {
 			activeHeader: "ui-icon-triangle-1-s",
@@ -199,24 +204,24 @@
 			toFocus = false;
 
 		switch ( event.keyCode ) {
-		case keyCode.RIGHT:
-		case keyCode.DOWN:
-			toFocus = this.headers[ ( currentIndex + 1 ) % length ];
-			break;
-		case keyCode.LEFT:
-		case keyCode.UP:
-			toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
-			break;
-		case keyCode.SPACE:
-		case keyCode.ENTER:
-			this._eventHandler( event );
-			break;
-		case keyCode.HOME:
-			toFocus = this.headers[ 0 ];
-			break;
-		case keyCode.END:
-			toFocus = this.headers[ length - 1 ];
-			break;
+			case keyCode.RIGHT:
+			case keyCode.DOWN:
+				toFocus = this.headers[ ( currentIndex + 1 ) % length ];
+				break;
+			case keyCode.LEFT:
+			case keyCode.UP:
+				toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
+				break;
+			case keyCode.SPACE:
+			case keyCode.ENTER:
+				this._eventHandler( event );
+				break;
+			case keyCode.HOME:
+				toFocus = this.headers[ 0 ];
+				break;
+			case keyCode.END:
+				toFocus = this.headers[ length - 1 ];
+				break;
 		}
 
 		if ( toFocus ) {
@@ -239,15 +244,15 @@
 
 		// Was collapsed or no panel
 		if ( ( options.active === false && options.collapsible === true ) ||
-				!this.headers.length ) {
+			!this.headers.length ) {
 			options.active = false;
 			this.active = $();
 
-		// active false only when collapsible is true
+			// active false only when collapsible is true
 		} else if ( options.active === false ) {
 			this._activate( 0 );
 
-		// was active, but active panel is gone
+			// was active, but active panel is gone
 		} else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
 
 			// all remaining panel are disabled
@@ -255,12 +260,12 @@
 				options.active = false;
 				this.active = $();
 
-			// activate previous panel
+				// activate previous panel
 			} else {
 				this._activate( Math.max( 0, options.active - 1 ) );
 			}
 
-		// was active, active panel still exists
+			// was active, active panel still exists
 		} else {
 
 			// make sure active index is correct
@@ -276,7 +281,11 @@
 		var prevHeaders = this.headers,
 			prevPanels = this.panels;
 
-		this.headers = this.element.find( this.options.header );
+		if ( typeof this.options.header === "function" ) {
+			this.headers = this.options.header( this.element );
+		} else {
+			this.headers = this.element.find( this.options.header );
+		}
 		this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
 			"ui-state-default" );
 
@@ -313,20 +322,20 @@
 				panel.attr( "aria-labelledby", headerId );
 			} )
 			.next()
-				.attr( "role", "tabpanel" );
+			.attr( "role", "tabpanel" );
 
 		this.headers
 			.not( this.active )
-				.attr( {
-					"aria-selected": "false",
-					"aria-expanded": "false",
-					tabIndex: -1
-				} )
-				.next()
-					.attr( {
-						"aria-hidden": "true"
-					} )
-					.hide();
+			.attr( {
+				"aria-selected": "false",
+				"aria-expanded": "false",
+				tabIndex: -1
+			} )
+			.next()
+			.attr( {
+				"aria-hidden": "true"
+			} )
+			.hide();
 
 		// Make sure at least one header is in the tab order
 		if ( !this.active.length ) {
@@ -338,9 +347,9 @@
 				tabIndex: 0
 			} )
 				.next()
-					.attr( {
-						"aria-hidden": "false"
-					} );
+				.attr( {
+					"aria-hidden": "false"
+				} );
 		}
 
 		this._createIcons();
@@ -445,11 +454,11 @@
 
 		if (
 
-				// click on active header, but not collapsible
-				( clickedIsActive && !options.collapsible ) ||
+			// click on active header, but not collapsible
+			( clickedIsActive && !options.collapsible ) ||
 
-				// allow canceling activation
-				( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
+			// allow canceling activation
+			( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
 			return;
 		}
 
@@ -525,11 +534,11 @@
 		toShow
 			.attr( "aria-hidden", "false" )
 			.prev()
-				.attr( {
-					"aria-selected": "true",
-					"aria-expanded": "true",
-					tabIndex: 0
-				} );
+			.attr( {
+				"aria-selected": "true",
+				"aria-expanded": "true",
+				tabIndex: 0
+			} );
 	},
 
 	_animate: function( toShow, toHide, data ) {
@@ -607,4 +616,4 @@
 	}
 } );
 
-} ) );
+} );