WIP: jQuery 1.8.0

Review Request #3267 — Created Aug. 10, 2012 and submitted

Information

Review Board

Reviewers

Update the current jquery library to 1.8.0.

This release is 13kbs larger than the currently used 1.3.2. (32kb vs 19kb)

Some methods/functions used in RB might have been deprecated. See http://api.jquery.com/category/deprecated/.

This update hosts all updates/improvements from 1.4 to 1.8. 

All release notes:

1.8: http://blog.jquery.com/2012/08/09/jquery-1-8-released/
1.7: http://blog.jquery.com/2011/11/03/jquery-1-7-released/
1.6: http://blog.jquery.com/2011/05/03/jquery-16-released/
1.5: http://blog.jquery.com/2011/01/31/jquery-15-released/
1.4: http://jquery14.com/day-01/jquery-14

Notable improvements: 

This update would bring in multiple performance improvements: 
- Faster selectors, events, and popular methods
- Better cross-browser compatibility
- Use of new methods and syntax

Djblets might require an update as well.
Local dev. Things seem to be working so far. No errors.

More testing to be done.
Description From Last Updated

This (and the other live() replacements in this change) don't look correct. In jQuery 1.7+, this should be done as: …

chipx86chipx86

In the dictionary-based on() cases, we shouldn't quote the names.

chipx86chipx86

Same comments here about dictionary-based event handling for on(). There's more uses like this in this change.

chipx86chipx86
ME
ME
chipx86
  1. 
      
  2. reviewboard/static/rb/js/common.js (Diff revision 3)
     
     
    Show all issues
    This (and the other live() replacements in this change) don't look correct.
    
    In jQuery 1.7+, this should be done as:
    
    $(document).on('click', this, ...);
    
    Second argument is the selector that live() was previously called on, and instead you use on() on $(document).
    1. So maybe I don't fully understand what you're saying, but:
      
      $('.foo').on('click', fi);
      
      Means whenever a click event occurs on element matching selector '.foo', fi will execute.
      
      Therefore:
      
      $('.foo').on('click', fi); == $('.foo').on('click', this, fi); 
      
      since "this" is the implicit selection since it represents "the selected element" that is '.foo'.
      
      I believe that parameter is used to replace the selector, e.g.:
      
      $('.foo').find('.fum tr').on('click', fi); == $('.foo').on('click', '.fum tr', fi); == $('.foo .fum tr').on('click', fi);
      
      
      I hope that makes sense.
      
      ------------------------------------------------------------------------------------------------
      From http://api.jquery.com/on/:
      
      .on( events [, selector] [, data], handler(eventObject) )
      
      selector
      A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
      
      
    2. Previously, live() would apply to all matching selectors now and in the future. What it really did was listen for bubbled events from some point on. That point was document by default, regardless of the selector. It was a bit slow, since everything had to bubble, and lots of things would be registered.
      
      One of the advantages to on() is that you can do the same thing but choose a starting point. To get the equivalent of live(), you use document. To fine-tune it, you can figure out the base selector that is the one parent for everything we'll ever listen to, which is nice in some cases. But a direct equivalent is document().
      
      You can even see what live() now does:
      
          live: function( types, data, fn ) {
              jQuery( this.context ).on( types, this.selector, data, fn );
              return this;
          }
      
      
      The docs for live() give examples for the equivalent and shows the use of $(document).on(.., selector, ..). Since in the standard case, .on() is equivalent to bind(), it would be wrong to match all future elements matching the selector (that's only wanted in certain cases, not all), and so they've changed the syntax when asking for the equivalent to live().
      
      From the docs:
      
      -----------------------------------------------------------------------------------------------
      
      Rewriting the .live() method in terms of its successors is straightforward; these are templates for equivalent calls for all three event attachment methods:
      
      $(selector).live(events, data, handler);                // jQuery 1.3+
      $(document).delegate(selector, events, data, handler);  // jQuery 1.4.3+
      $(document).on(events, selector, data, handler);        // jQuery 1.7+
    3. I see what you mean. I actually thought .on combined .bind and .live, but this makes so much more sense. Thanks.
  3. reviewboard/static/rb/js/diffviewer.js (Diff revision 3)
     
     
    Show all issues
    In the dictionary-based on() cases, we shouldn't quote the names.
  4. reviewboard/static/rb/js/reviews.js (Diff revision 3)
     
     
    Show all issues
    Same comments here about dictionary-based event handling for on().
    
    There's more uses like this in this change.
  5. 
      
chipx86
  1. I went ahead and fixed the live() calls and fixed some other issues with AJAX and file/screenshot uploading and am committing. Thanks!
  2. 
      
ME
Review request changed
Status:
Completed
Change Summary:
Made some fixes and pushed to master (74c7d3a)