[wp-trac] [WordPress Trac] #38806: Better wp namespace in customize-base.js

WordPress Trac noreply at wordpress.org
Wed Nov 16 08:07:18 UTC 2016


#38806: Better wp namespace in customize-base.js
--------------------------+------------------------------
 Reporter:  afercia       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Customize     |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:  javascript
--------------------------+------------------------------

Comment (by afercia):

 @westonruter yep I know `grunt jshint` doesn't catch it because it's set
 as global in `.jshintrc`. I was wondering why there's  a so great variety
 of different conventions across all the JS files, this can be confusing
 for new contributors. So here, `window.wp = window.wp || {};` is used just
 to make sure the object is created, then `wp` is passed regardless if it's
 defined or not.

 In many other cases `window.wp` is explicitly passed. In other cases
 ''nothing'' is expliicitly passed, see for example `password-strength-
 meter.js`.  In other cases again `window.wp = window.wp || {};` is used
 inside the IIFE, which is OK but sometimes it's ''after'' other references
 to `wp`.

 I was going to open a ticket for each case, but honestly they're so many
 that I gave up :) Thinking that establishing a convention would have some
 value though.

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


More information about the wp-trac mailing list