[wp-trac] [WordPress Trac] #36449: When concatenating styles in script-loader dependencies may not be honoured.

WordPress Trac noreply at wordpress.org
Fri Apr 8 09:43:09 UTC 2016


#36449: When concatenating styles in script-loader dependencies may not be
honoured.
---------------------------+-----------------------------
 Reporter:  gitlost        |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Script Loader  |    Version:  4.4.2
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 This is the (not-really) evil twin of the scripts issue
 [https://core.trac.wordpress.org/ticket/36448 36448].

 When concatenating styles, dependencies may not be honoured for styles
 that trigger the use of `$print_html` (ie those outside the default
 directories or having conditionals or alts).

 For instance this test where `three` depends on `one` and `one` has a
 conditional:

 {{{#!php
 <?php
 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&dir=ltr&load%5B%5D=two,three&ver=1'
 type='text/css' media='all' />\n";

         $this->assertEquals( $expected, $print_styles );
         $this->assertEquals( '', $wp_print_styles );
 }
 }}}

 will fail, as the conditional stuff will always be outputted after the
 concatenated styles, resulting in `one` appearing after `three`:

 {{{
 <link rel='stylesheet' href='/wp-admin/load-
 styles.php?c=0&dir=ltr&load%5B%5D=two,three&ver=1'
 type='text/css' media='all' />
 <!--[if blah]>
 <link rel='stylesheet' id='one-css'  href='/directory/one.js?ver=1'
 type='text/css' media='all' />
 <![endif]-->
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36449>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list