[wp-trac] [WordPress Trac] #38729: Script Conditional does not work for !IE

WordPress Trac noreply at wordpress.org
Wed Nov 9 07:50:40 UTC 2016


#38729: Script Conditional does not work for !IE
---------------------------+-----------------------------
 Reporter:  shaunjeffrey   |      Owner:
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Script Loader  |    Version:  4.6.1
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 Hi team,

 It seems that when adding the wp_script_add_data function for use with IE
 conditional statements, the most important one was not considered; the
 situation where you want a script to load when the user is using a non-IE
 browser, or an IE browser over 9.

 Because of the fact that conditional statements only work in IE 9 and
 below, we would either need to (1) add a new key, (2) add an additional
 flag, (3) parse the data and hope for the best, or (4) apply a new filter
 for both $cond_before and $cond_after, and pass in the the handle as a
 reference.

 Option 1 above would probably be easiest to implement, for instance, as
 well as checking
 {{{
     $conditional = isset( $obj->extra['conditional'] ) ?
 $obj->extra['conditional'] : '';
 }}}
 We could also check
 {{{
     $not_conditional = isset( $obj->extra['not-conditional'] ) ?
 $obj->extra['not-conditional'] : '';
 }}}
 And instead of
 {{{
     $cond_before = "<!--[if {$conditional}]>\n";
     $cond_after = "<!\[endif]-->\n";
 }}}
 We'd have
 {{{
     $cond_before = "<!--[if {$not_conditional}]-->\n";
     $cond_after = "<!--\[endif]-->\n";
 }}}

 Alternatively, Option 4 would be the most expandable. We could then add
 two apply_filters, one inside each check for
 {{{
 if ( $has_conditional_data )
 }}}
 And then the user would be able to manually adjust the conditional
 statements as required.

 From what I can tell, the same limitation exists for styles, and we're
 unable to to set non-IE styles. Again, applying filters would be the most
 adaptable way to adjust these conditional statements.

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


More information about the wp-trac mailing list