jQuery Core Team Meeting – Sep 11 2014


Location: In person, Chicago jQCon

Attending: DaveMethvin, markelog, gibson042, m_gol

link Versioning

  • If we are going npm we should obey semantic versioning
  • The .then() change will be breaking
  • Might as well remove other things like .andSelf()
  • New versioning
    • 1.x now jquery-legacy-3.x
    • 2.x now jquery 3.x

link Deferred pull request for Promise/A compat on .then()

link xhr

  • Design goal: allow standalone usage
  • Simple xhr module in a wrapper
1
2
3
4
5
6
7
8
9
10
jQuery.xhr = require("jquery-xhr");
jQuery.xhr.Promise = window.Promise || function( executor ) {
var dfd = jQuery.Deferred();
try {
executor( dfd.resolve, dfd.reject );
} catch ( ex ) {
dfd.reject( ex );
}
return dfd.promise();
};
  • Simple case: jQuery.xhr( url, options ).then( handlerA ).then( handlerB )
  • beforeSend case:
1
2
3
4
5
xhr = jQuery.xhr( url, { autosend: false } ).set( … );
jQuery.xhr({ url: ... });
jQuery.xhr( url );
xhr.then( handlerA );
xhr.send( body ).then( handlerB )
  • Super-advanced case:
1
2
3
4
5
6
xhr = jQuery.xhr( url, { autosend: false } );
xhr.then( handlerA );
if ( badFeeling(xhr.getNative()) ) { xhr.abort(); }
xhr.send( body ).then( handlerB );
Promise.resolve( xhr ).then( … )
jQuery.xhr( url ).send({ ... }), jQuery.xhr( url )
  • Does an unsent Promise that has mutability violate the Promise/A+ spec? Or does the mutability only apply to the resolution? No. Does not appear to apply to the returned promise, which can be augmented, only to the resolved value of the promise
  • options necessary to functionality: method, user, pass, body, query (RFC), beforeSend
  • options nice to keep: cache, ifModified, headers
  • jxrPromise: .abort(), .xhr property
    • Rejects on: Exception, timeout, abort
  • what about 4xx/5xx? or a 0 (network error)
    • implied success: jQuery.xhr( url ).then( jQuery.xhr.rejectHTTPError )
    • implied failure: jQuery.xhr( url ).catch( jQuery.xhr.ifResponse )
  • Resolved value: raw native xhr
  • Rejected value: Error object, potentially with .xhr property, .options object