Index: src/wp-includes/class.wp-styles.php
===================================================================
--- src/wp-includes/class.wp-styles.php	(revision 37167)
+++ src/wp-includes/class.wp-styles.php	(working copy)
@@ -62,6 +62,17 @@
 	 * @var string
 	 */
 	public $concat = '';
+	/**
+	 * If concatenating, holds arrays of data batched in dependency order.
+	 * 'concat' holds the handles to concatenate (comma-separated),
+	 * 'print_code' inline styles for handles in 'concat' (will be enclosed in '<style>' tags),
+	 * 'print_html' HTML markup of styles and additional data and inline styles not in 'print_code'.
+	 *
+	 * @since 4.5
+	 * @access public
+	 * @var array
+	 */
+	public $concats = array( array( 'concat' => '', 'print_code' => '', 'print_html' => '' ) );
 
 	/**
 	 * Holds a string which contains style handles and their version.
@@ -83,25 +94,6 @@
 	public $do_concat = false;
 
 	/**
-	 * Holds HTML markup of styles and additional data if concatenation
-	 * is enabled.
-	 *
-	 * @since 2.8.0
-	 * @access public
-	 * @var string
-	 */
-	public $print_html = '';
-
-	/**
-	 * Holds inline styles if concatenation is enabled.
-	 *
-	 * @since 3.3.0
-	 * @access public
-	 * @var string
-	 */
-	public $print_code = '';
-
-	/**
 	 * List of default directories.
 	 *
 	 * @since 2.8.0
@@ -152,12 +144,15 @@
 			$ver = $ver ? $ver . '&amp;' . $this->args[$handle] : $this->args[$handle];
 
 		if ( $this->do_concat ) {
-			if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) {
-				$this->concat .= "$handle,";
+
+			$in_default_dir = $this->in_default_dir( $obj->src );
+
+			if ( $in_default_dir && ! isset( $obj->extra['conditional'] ) && ! isset( $obj->extra['alt'] ) ) {
+				$concat_idx = count( $this->concats ) - 1;
+				$this->concats[$concat_idx]['concat'] .= "$handle,";
+				$this->concats[$concat_idx]['print_code'] .= $this->print_inline_style( $handle, false );
 				$this->concat_version .= "$handle$ver";
 
-				$this->print_code .= $this->print_inline_style( $handle, false );
-
 				return true;
 			}
 		}
@@ -172,7 +167,8 @@
 			if ( $inline_style = $this->print_inline_style( $handle, false ) ) {
 				$inline_style = sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style );
 				if ( $this->do_concat ) {
-					$this->print_html .= $inline_style;
+					$concat_idx = count( $this->concats ) - 1;
+					$this->concats[$concat_idx]['print_html'] .= $inline_style;
 				} else {
 					echo $inline_style;
 				}
@@ -226,12 +222,17 @@
 		}
 
 		if ( $this->do_concat ) {
-			$this->print_html .= $conditional_pre;
-			$this->print_html .= $tag;
+			$concat_idx = count( $this->concats ) - 1;
+			$this->concats[$concat_idx]['print_html'] .= $conditional_pre;
+			$this->concats[$concat_idx]['print_html'] .= $tag;
 			if ( $inline_style = $this->print_inline_style( $handle, false ) ) {
-				$this->print_html .= sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style );
+				$this->concats[$concat_idx]['print_html'] .= sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style );
 			}
-			$this->print_html .= $conditional_post;
+			$this->concats[$concat_idx]['print_html'] .= $conditional_post;
+			// To maintain dependency order, need to bump batch to next level if wasn't concatenated above.
+			if ( ! ( $in_default_dir && ! isset( $obj->extra['conditional'] ) && ! isset( $obj->extra['alt'] ) ) ) {
+				$this->concats[] = array( 'concat' => '', 'print_code' => '', 'print_html' => '' );
+			}
 		} else {
 			echo $conditional_pre;
 			echo $tag;
@@ -400,8 +401,7 @@
 	 */
 	public function reset() {
 		$this->do_concat = false;
-		$this->concat = '';
+		$this->concats = array( array( 'concat' => '', 'print_code' => '', 'print_html' => '' ) );
 		$this->concat_version = '';
-		$this->print_html = '';
 	}
 }
Index: src/wp-includes/script-loader.php
===================================================================
--- src/wp-includes/script-loader.php	(revision 37167)
+++ src/wp-includes/script-loader.php	(working copy)
@@ -1166,25 +1166,29 @@
 	if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
 		$zip = 'gzip';
 
-	if ( $concat = trim( $wp_styles->concat, ', ' ) ) {
-		$dir = $wp_styles->text_direction;
-		$ver = $wp_styles->default_version;
+	foreach ( $wp_styles->concats as $concat_entry ) {
+		$concat = trim( $concat_entry['concat'], ', ' );
+		if ( '' !== $concat ) {
+			$dir = $wp_styles->text_direction;
+			$ver = $wp_styles->default_version;
 
-		$concat = str_split( $concat, 128 );
-		$concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat );
+			$concat = str_split( $concat, 128 );
+			$concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat );
 
-		$href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&" . $concat . '&ver=' . $ver;
-		echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
+			$href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&" . $concat . '&ver=' . $ver;
+			echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
+		}
 
-		if ( !empty($wp_styles->print_code) ) {
+		if ( '' !== $concat_entry['print_code'] ) {
 			echo "<style type='text/css'>\n";
-			echo $wp_styles->print_code;
+			echo $concat_entry['print_code'];
 			echo "\n</style>\n";
 		}
+
+		if ( '' !== $concat_entry['print_html'] ) {
+			echo $concat_entry['print_html'];
+		}
 	}
-
-	if ( !empty($wp_styles->print_html) )
-		echo $wp_styles->print_html;
 }
 
 /**
Index: tests/phpunit/tests/dependencies/styles.php
===================================================================
--- tests/phpunit/tests/dependencies/styles.php	(revision 37167)
+++ tests/phpunit/tests/dependencies/styles.php	(working copy)
@@ -136,7 +136,8 @@
 		wp_add_inline_style( 'handle', $style );
 
 		wp_print_styles();
-		$this->assertEquals( $expected, $wp_styles->print_html );
+		$print_styles = get_echo( '_print_styles' );
+		$this->assertEquals( $expected, $print_styles );
 
 	}
 
@@ -298,4 +299,32 @@
 			),
 		);
 	}
+
+	/**
+	 * @ticket wp_style_conditional_concat_dependency
+	 */
+	public function test_wp_style_conditional_concat_dependency() {
+		global $wp_styles;
+
+		$wp_styles->do_concat = true;
+		$wp_styles->default_dirs = array( '/directory/' );
+		$wp_styles->default_version = 1;
+
+		wp_enqueue_style( 'one', '/directory/one.js', array(), 1 );
+		wp_enqueue_style( 'two', '/directory/two.js', array(), 1 );
+		wp_enqueue_style( 'three', '/directory/three.js', array( 'one' ), 1 );
+
+		wp_style_add_data( 'one', 'conditional', 'blah' );
+
+		$wp_print_styles = get_echo( 'wp_print_styles' );
+		$print_styles = get_echo( '_print_styles' );
+
+		$expected  = "<!--[if blah]>\n";
+		$expected .= "<link rel='stylesheet' id='one-css'  href='/directory/one.js?ver=1' type='text/css' media='all' />\n";
+		$expected .= "<![endif]-->\n";
+		$expected .= "<link rel='stylesheet' href='/wp-admin/load-styles.php?c=0&amp;dir=ltr&amp;load%5B%5D=two,three&amp;ver=1' type='text/css' media='all' />\n";
+
+		$this->assertEquals( $expected, $print_styles );
+		$this->assertEquals( '', $wp_print_styles );
+	}
 }
