Make WordPress Core

Opened 10 years ago

Last modified 17 months ago

#16118 new enhancement

Support for wp_enqueue_style with negative conditional comments — at Version 1

Reported by: sayontan Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.4
Component: Script Loader Keywords: has-patch needs-testing dev-feedback 3.6-early
Focuses: Cc:

Description (last modified by nacin)

Please refer to #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"/>

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' />

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".

Change History (2)

#1 @nacin
10 years ago

  • Description modified (diff)
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to enhancement
Note: See TracTickets for help on using tickets.