Opened 11 years ago
Closed 11 years ago
#25427 closed defect (bug) (duplicate)
wp_style_add_data() doesn't support "downlevel-revealed" conditional comments
Reported by: | pburke | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.6.1 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
When used to add conditional comments to enqueued stylesheets, wp_style_add_data() generates code that works great for targeting specific versions of Internet Explorer ('lt IE 9' etc.), but does not work for targeting non-IE browsers ('!IE' or '!IEMobile').
Those types of conditional comments are called "downlevel-revealed" comments, and need a specific syntax so they are read by non-IE browsers but hidden by IE:
<!--[if !IE]><!--> ... <!--<![endif]-->
The syntax generated by wp_style_add_data() is:
<!--[if !IE]> ... <![endif]-->
... which causes the contained code to be ignored by non-IE browsers.
To reproduce:
1) In a theme's functions.php file, use wp_style_add_data() to attach a conditional comment that targets non-IE browsers to the theme's stylesheet:
wp_enqueue_style( 'mytheme-style', get_stylesheet_uri(), array(), '2013-09-27' ); wp_style_add_data( 'mytheme-style', 'conditional', '!IE' );
2) Enable the theme and view the page in a non-IE browser. Notice that the browser ignores the stylesheet declaration.
Reference: downlevel-revealed versus downlevel-hidden conditional comments.
#16118, #21162, #22122