[wp-trac] [WordPress Trac] #16118: Support for wp_enqueue_style with negative conditional comments

WordPress Trac wp-trac at lists.automattic.com
Thu Jan 6 06:18:41 UTC 2011


#16118: Support for wp_enqueue_style with negative conditional comments
--------------------------+-----------------------------
 Reporter:  sayontan      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  3.0.4
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Please refer to http://core.trac.wordpress.org/ticket/10891. It refers to
 the support for conditional comments using the global variable, wp_styles.

 I have noticed that if you pass a negative conditional comment, however,
 this breaks. E.g. Let's say you have a lot of CSS3 rules, which don't
 apply to IE. You would not include that CSS:

 {{{
 <!--[if !IE]>-->
 <link rel="stylesheet" id="my-handle-css"
 href="http://my.url.com/css3.css" type="text/css" media="all"/>
 <!--<![endif]-->
 }}}

 I know that IE9 supports CSS3, but I am using the above for illustrative
 purposes. One would expect that to include the conditional comment above
 you would do this between the register and the enqueue commands:

 {{{
 $GLOBALS['wp_styles']->add_data('my-handle', 'conditional', '!IE');
 }}}

 If you add a conditional tag to wp_styles, however, the generated markup
 is incorrect:

 {{{
 <!--[if !IE]>
 <link rel='stylesheet' id='my-handle-css'
 href='http://my.url.com/css3.css' type='text/css' media='all' />
 <![endif]-->
 }}}

 Note the missing --> after [if !IE]>, and <!-- before <![endif]. This has
 the effect of hiding the CSS from all browsers, which wasn't the original
 intention. So probably a separate handling approach is required for "show"
 type of conditional comments than for "hide".

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16118>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list