[wp-trac] [WordPress Trac] #16024: Conditional Comments for JS

WordPress Trac noreply at wordpress.org
Tue Jan 27 03:44:45 UTC 2015


#16024: Conditional Comments for JS
--------------------------------------------------+-----------------------
 Reporter:  filosofo                              |       Owner:  azaozz
     Type:  enhancement                           |      Status:  reopened
 Priority:  high                                  |   Milestone:  4.2
Component:  Script Loader                         |     Version:  3.1
 Severity:  normal                                |  Resolution:
 Keywords:  has-patch needs-testing dev-feedback  |     Focuses:  template
--------------------------------------------------+-----------------------

Comment (by valendesigns):

 Replying to [comment:95 nacin]:
 >  * That single test should be broken up into multiple tests. A good rule
 of thumb is one assertion per test. Obviously, multiple assertions testing
 the same thing are OK. A general example would be asserting that the array
 length is 3 and that it contains X key. An example specific to this would
 be to assert the printed scripts then confirm there is nothing left to
 print.

 I've broken up the single test into multiple tests in
 [attachment:16024.10.diff].

 >  * wp_script_add_data() has the potential to replace
 wp_localize_script(). Is there some kind of method signature that would be
 ideal to replace wp_localize_script() that the current signature would
 prevent? Thinking forwards compatibility here.

 In order to replace `wp_localize_script` we would likely need to add
 another parameter for `name` and add support for the `localize` key, as
 `data` and `conditional` are the only two keys that print to the screen
 AFAIK.

 Alternatively, we could make it so any keys other than `data` and
 `conditional` are treated as `name`, but only if an array is passed in as
 the value. Otherwise, it is treated as an invalid key.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/16024#comment:98>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list