diff --git a/build/io-base/io-base-coverage.js b/build/io-base/io-base-coverage.js index 431684a08c0..1db0ff0488c 100644 --- a/build/io-base/io-base-coverage.js +++ b/build/io-base/io-base-coverage.js @@ -26,10 +26,10 @@ _yuitest_coverage["build/io-base/io-base.js"] = { path: "build/io-base/io-base.js", code: [] }; -_yuitest_coverage["build/io-base/io-base.js"].code=["YUI.add('io-base', function (Y, NAME) {","","/**","Base IO functionality. Provides basic XHR transport support.","","@module io","@submodule io-base","@for IO","**/","","var // List of events that comprise the IO event lifecycle."," EVENTS = ['start', 'complete', 'end', 'success', 'failure', 'progress'],",""," // Whitelist of used XHR response object properties."," XHR_PROPS = ['status', 'statusText', 'responseText', 'responseXML'],",""," win = Y.config.win,"," uid = 0;","","/**","The IO class is a utility that brokers HTTP requests through a simplified","interface. Specifically, it allows JavaScript to make HTTP requests to","a resource without a page reload. The underlying transport for making","same-domain requests is the XMLHttpRequest object. IO can also use","Flash, if specified as a transport, for cross-domain requests.","","@class IO","@constructor","@param {Object} config Object of EventTarget's publish method configurations"," used to configure IO's events.","**/","function IO (config) {"," var io = this;",""," io._uid = 'io:' + uid++;"," io._init(config);"," Y.io._map[io._uid] = io;","}","","IO.prototype = {"," //--------------------------------------"," // Properties"," //--------------------------------------",""," /**"," * A counter that increments for each transaction."," *"," * @property _id"," * @private"," * @type {Number}"," */"," _id: 0,",""," /**"," * Object of IO HTTP headers sent with each transaction."," *"," * @property _headers"," * @private"," * @type {Object}"," */"," _headers: {"," 'X-Requested-With' : 'XMLHttpRequest'"," },",""," /**"," * Object that stores timeout values for any transaction with a defined"," * \"timeout\" configuration property."," *"," * @property _timeout"," * @private"," * @type {Object}"," */"," _timeout: {},",""," //--------------------------------------"," // Methods"," //--------------------------------------",""," _init: function(config) {"," var io = this, i, len;",""," io.cfg = config || {};",""," Y.augment(io, Y.EventTarget);"," for (i = 0, len = EVENTS.length; i < len; ++i) {"," // Publish IO global events with configurations, if any."," // IO global events are set to broadcast by default."," // These events use the \"io:\" namespace."," io.publish('io:' + EVENTS[i], Y.merge({ broadcast: 1 }, config));"," // Publish IO transaction events with configurations, if"," // any. These events use the \"io-trn:\" namespace."," io.publish('io-trn:' + EVENTS[i], config);"," }"," },",""," /**"," * Method that creates a unique transaction object for each request."," *"," * @method _create"," * @private"," * @param {Object} cfg Configuration object subset to determine if"," * the transaction is an XDR or file upload,"," * requiring an alternate transport."," * @param {Number} id Transaction id"," * @return {Object} The transaction object"," */"," _create: function(config, id) {"," var io = this,"," transaction = {"," id : Y.Lang.isNumber(id) ? id : io._id++,"," uid: io._uid"," },"," alt = config.xdr ? config.xdr.use : null,"," form = config.form && config.form.upload ? 'iframe' : null,"," use;",""," if (alt === 'native') {"," // Non-IE and IE >= 10 can use XHR level 2 and not rely on an"," // external transport."," alt = Y.UA.ie && !SUPPORTS_CORS ? 'xdr' : null;",""," // Prevent \"pre-flight\" OPTIONS request by removing the"," // `X-Requested-With` HTTP header from CORS requests. This header"," // can be added back on a per-request basis, if desired."," io.setHeader('X-Requested-With');"," }",""," use = alt || form;"," transaction = use ? Y.merge(Y.IO.customTransport(use), transaction) :"," Y.merge(Y.IO.defaultTransport(), transaction);",""," if (transaction.notify) {"," config.notify = function (e, t, c) { io.notify(e, t, c); };"," }",""," if (!use) {"," if (win && win.FormData && config.data instanceof win.FormData) {"," transaction.c.upload.onprogress = function (e) {"," io.progress(transaction, e, config);"," };"," transaction.c.onload = function (e) {"," io.load(transaction, e, config);"," };"," transaction.c.onerror = function (e) {"," io.error(transaction, e, config);"," };"," transaction.upload = true;"," }"," }",""," return transaction;"," },",""," _destroy: function(transaction) {"," if (win && !transaction.notify && !transaction.xdr) {"," if (XHR && !transaction.upload) {"," transaction.c.onreadystatechange = null;"," } else if (transaction.upload) {"," transaction.c.upload.onprogress = null;"," transaction.c.onload = null;"," transaction.c.onerror = null;"," } else if (Y.UA.ie && !transaction.e) {"," // IE, when using XMLHttpRequest as an ActiveX Object, will throw"," // a \"Type Mismatch\" error if the event handler is set to \"null\"."," transaction.c.abort();"," }"," }",""," transaction = transaction.c = null;"," },",""," /**"," * Method for creating and firing events."," *"," * @method _evt"," * @private"," * @param {String} eventName Event to be published."," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration data subset for event subscription."," */"," _evt: function(eventName, transaction, config) {"," var io = this, params,"," args = config['arguments'],"," emitFacade = io.cfg.emitFacade,"," globalEvent = \"io:\" + eventName,"," trnEvent = \"io-trn:\" + eventName;",""," // Workaround for #2532107"," this.detach(trnEvent);",""," if (transaction.e) {"," transaction.c = { status: 0, statusText: transaction.e };"," }",""," // Fire event with parameters or an Event Facade."," params = [ emitFacade ?"," {"," id: transaction.id,"," data: transaction.c,"," cfg: config,"," 'arguments': args"," } :"," transaction.id"," ];",""," if (!emitFacade) {"," if (eventName === EVENTS[0] || eventName === EVENTS[2]) {"," if (args) {"," params.push(args);"," }"," } else {"," if (transaction.evt) {"," params.push(transaction.evt);"," } else {"," params.push(transaction.c);"," }"," if (args) {"," params.push(args);"," }"," }"," }",""," params.unshift(globalEvent);"," // Fire global events."," io.fire.apply(io, params);"," // Fire transaction events, if receivers are defined."," if (config.on) {"," params[0] = trnEvent;"," io.once(trnEvent, config.on[eventName], config.context || Y);"," io.fire.apply(io, params);"," }"," },",""," /**"," * Fires event \"io:start\" and creates, fires a transaction-specific"," * start event, if `config.on.start` is defined."," *"," * @method start"," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration object for the transaction."," */"," start: function(transaction, config) {"," /**"," * Signals the start of an IO request."," * @event io:start"," */"," this._evt(EVENTS[0], transaction, config);"," },",""," /**"," * Fires event \"io:complete\" and creates, fires a"," * transaction-specific \"complete\" event, if config.on.complete is"," * defined."," *"," * @method complete"," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration object for the transaction."," */"," complete: function(transaction, config) {"," /**"," * Signals the completion of the request-response phase of a"," * transaction. Response status and data are accessible, if"," * available, in this event."," * @event io:complete"," */"," this._evt(EVENTS[1], transaction, config);"," },",""," /**"," * Fires event \"io:end\" and creates, fires a transaction-specific \"end\""," * event, if config.on.end is defined."," *"," * @method end"," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration object for the transaction."," */"," end: function(transaction, config) {"," /**"," * Signals the end of the transaction lifecycle."," * @event io:end"," */"," this._evt(EVENTS[2], transaction, config);"," this._destroy(transaction);"," },",""," /**"," * Fires event \"io:success\" and creates, fires a transaction-specific"," * \"success\" event, if config.on.success is defined."," *"," * @method success"," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration object for the transaction."," */"," success: function(transaction, config) {"," /**"," * Signals an HTTP response with status in the 2xx range."," * Fires after io:complete."," * @event io:success"," */"," this._evt(EVENTS[3], transaction, config);"," this.end(transaction, config);"," },",""," /**"," * Fires event \"io:failure\" and creates, fires a transaction-specific"," * \"failure\" event, if config.on.failure is defined."," *"," * @method failure"," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration object for the transaction."," */"," failure: function(transaction, config) {"," /**"," * Signals an HTTP response with status outside of the 2xx range."," * Fires after io:complete."," * @event io:failure"," */"," this._evt(EVENTS[4], transaction, config);"," this.end(transaction, config);"," },",""," /**"," * Fires event \"io:progress\" and creates, fires a transaction-specific"," * \"progress\" event -- for XMLHttpRequest file upload -- if"," * config.on.progress is defined."," *"," * @method progress"," * @param {Object} transaction Transaction object."," * @param {Object} progress event."," * @param {Object} config Configuration object for the transaction."," */"," progress: function(transaction, e, config) {"," /**"," * Signals the interactive state during a file upload transaction."," * This event fires after io:start and before io:complete."," * @event io:progress"," */"," transaction.evt = e;"," this._evt(EVENTS[5], transaction, config);"," },",""," /**"," * Fires event \"io:complete\" and creates, fires a transaction-specific"," * \"complete\" event -- for XMLHttpRequest file upload -- if"," * config.on.complete is defined."," *"," * @method load"," * @param {Object} transaction Transaction object."," * @param {Object} load event."," * @param {Object} config Configuration object for the transaction."," */"," load: function (transaction, e, config) {"," transaction.evt = e.target;"," this._evt(EVENTS[1], transaction, config);"," },",""," /**"," * Fires event \"io:failure\" and creates, fires a transaction-specific"," * \"failure\" event -- for XMLHttpRequest file upload -- if"," * config.on.failure is defined."," *"," * @method error"," * @param {Object} transaction Transaction object."," * @param {Object} error event."," * @param {Object} config Configuration object for the transaction."," */"," error: function (transaction, e, config) {"," transaction.evt = e;"," this._evt(EVENTS[4], transaction, config);"," },",""," /**"," * Retry an XDR transaction, using the Flash tranport, if the native"," * transport fails."," *"," * @method _retry"," * @private"," * @param {Object} transaction Transaction object."," * @param {String} uri Qualified path to transaction resource."," * @param {Object} config Configuration object for the transaction."," */"," _retry: function(transaction, uri, config) {"," this._destroy(transaction);"," config.xdr.use = 'flash';"," return this.send(uri, config, transaction.id);"," },",""," /**"," * Method that concatenates string data for HTTP GET transactions."," *"," * @method _concat"," * @private"," * @param {String} uri URI or root data."," * @param {String} data Data to be concatenated onto URI."," * @return {String}"," */"," _concat: function(uri, data) {"," uri += (uri.indexOf('?') === -1 ? '?' : '&') + data;"," return uri;"," },",""," /**"," * Stores default client headers for all transactions. If a label is"," * passed with no value argument, the header will be deleted."," *"," * @method setHeader"," * @param {String} name HTTP header"," * @param {String} value HTTP header value"," */"," setHeader: function(name, value) {"," if (value) {"," this._headers[name] = value;"," } else {"," delete this._headers[name];"," }"," },",""," /**"," * Method that sets all HTTP headers to be sent in a transaction."," *"," * @method _setHeaders"," * @private"," * @param {Object} transaction - XHR instance for the specific transaction."," * @param {Object} headers - HTTP headers for the specific transaction, as"," * defined in the configuration object passed to YUI.io()."," */"," _setHeaders: function(transaction, headers) {"," headers = Y.merge(this._headers, headers);"," Y.Object.each(headers, function(value, name) {"," if (value !== 'disable') {"," transaction.setRequestHeader(name, headers[name]);"," }"," });"," },",""," /**"," * Starts timeout count if the configuration object has a defined"," * timeout property."," *"," * @method _startTimeout"," * @private"," * @param {Object} transaction Transaction object generated by _create()."," * @param {Object} timeout Timeout in milliseconds."," */"," _startTimeout: function(transaction, timeout) {"," var io = this;",""," io._timeout[transaction.id] = setTimeout(function() {"," io._abort(transaction, 'timeout');"," }, timeout);"," },",""," /**"," * Clears the timeout interval started by _startTimeout()."," *"," * @method _clearTimeout"," * @private"," * @param {Number} id - Transaction id."," */"," _clearTimeout: function(id) {"," clearTimeout(this._timeout[id]);"," delete this._timeout[id];"," },",""," /**"," * Method that determines if a transaction response qualifies as success"," * or failure, based on the response HTTP status code, and fires the"," * appropriate success or failure events."," *"," * @method _result"," * @private"," * @static"," * @param {Object} transaction Transaction object generated by _create()."," * @param {Object} config Configuration object passed to io()."," */"," _result: function(transaction, config) {"," var status;"," // Firefox will throw an exception if attempting to access"," // an XHR object's status property, after a request is aborted."," try {"," status = transaction.c.status;"," } catch(e) {"," status = 0;"," }",""," // IE reports HTTP 204 as HTTP 1223."," if (status >= 200 && status < 300 || status === 304 || status === 1223) {"," this.success(transaction, config);"," } else {"," this.failure(transaction, config);"," }"," },",""," /**"," * Event handler bound to onreadystatechange."," *"," * @method _rS"," * @private"," * @param {Object} transaction Transaction object generated by _create()."," * @param {Object} config Configuration object passed to YUI.io()."," */"," _rS: function(transaction, config) {"," var io = this;",""," if (transaction.c.readyState === 4) {"," if (config.timeout) {"," io._clearTimeout(transaction.id);"," }",""," // Yield in the event of request timeout or abort."," setTimeout(function() {"," io.complete(transaction, config);"," io._result(transaction, config);"," }, 0);"," }"," },",""," /**"," * Terminates a transaction due to an explicit abort or timeout."," *"," * @method _abort"," * @private"," * @param {Object} transaction Transaction object generated by _create()."," * @param {String} type Identifies timed out or aborted transaction."," */"," _abort: function(transaction, type) {"," if (transaction && transaction.c) {"," transaction.e = type;"," transaction.c.abort();"," }"," },",""," /**"," * Requests a transaction. `send()` is implemented as `Y.io()`. Each"," * transaction may include a configuration object. Its properties are:"," *"," *
"," *
method
"," *
HTTP method verb (e.g., GET or POST). If this property is not"," * not defined, the default value will be GET.
"," *"," *
data
"," *
This is the name-value string that will be sent as the"," * transaction data. If the request is HTTP GET, the data become"," * part of querystring. If HTTP POST, the data are sent in the"," * message body.
"," *"," *
xdr
"," *
Defines the transport to be used for cross-domain requests."," * By setting this property, the transaction will use the specified"," * transport instead of XMLHttpRequest. The properties of the"," * transport object are:"," *
"," *
use
"," *
The transport to be used: 'flash' or 'native'
"," *
dataType
"," *
Set the value to 'XML' if that is the expected response"," * content type.
"," *
"," *"," *
form
"," *
Form serialization configuration object. Its properties are:"," *
"," *
id
"," *
Node object or id of HTML form
"," *
useDisabled
"," *
`true` to also serialize disabled form field values"," * (defaults to `false`)
"," *
"," *"," *
on
"," *
Assigns transaction event subscriptions. Available events are:"," *
"," *
start
"," *
Fires when a request is sent to a resource.
"," *
complete
"," *
Fires when the transaction is complete.
"," *
success
"," *
Fires when the HTTP response status is within the 2xx"," * range.
"," *
failure
"," *
Fires when the HTTP response status is outside the 2xx"," * range, if an exception occurs, if the transation is aborted,"," * or if the transaction exceeds a configured `timeout`.
"," *
end
"," *
Fires at the conclusion of the transaction"," * lifecycle, after `success` or `failure`.
"," *
"," *"," *

Callback functions for `start` and `end` receive the id of the"," * transaction as a first argument. For `complete`, `success`, and"," * `failure`, callbacks receive the id and the response object"," * (usually the XMLHttpRequest instance). If the `arguments`"," * property was included in the configuration object passed to"," * `Y.io()`, the configured data will be passed to all callbacks as"," * the last argument.

"," *
"," *"," *
sync
"," *
Pass `true` to make a same-domain transaction synchronous."," * CAVEAT: This will negatively impact the user"," * experience. Have a very good reason if you intend to use"," * this.
"," *"," *
context
"," *
The \"`this'\" object for all configured event handlers. If a"," * specific context is needed for individual callbacks, bind the"," * callback to a context using `Y.bind()`.
"," *"," *
headers
"," *
Object map of transaction headers to send to the server. The"," * object keys are the header names and the values are the header"," * values.
"," *"," *
timeout
"," *
Millisecond threshold for the transaction before being"," * automatically aborted.
"," *"," *
arguments
"," *
User-defined data passed to all registered event handlers."," * This value is available as the second argument in the \"start\" and"," * \"end\" event handlers. It is the third argument in the \"complete\","," * \"success\", and \"failure\" event handlers. Be sure to quote"," * this property name in the transaction configuration as"," * \"arguments\" is a reserved word in JavaScript (e.g."," * `Y.io({ ..., \"arguments\": stuff })`).
"," *
"," *"," * @method send"," * @public"," * @param {String} uri Qualified path to transaction resource."," * @param {Object} config Configuration object for the transaction."," * @param {Number} id Transaction id, if already set."," * @return {Object}"," */"," send: function(uri, config, id) {"," var transaction, method, i, len, sync, data,"," io = this,"," u = uri,"," response = {};",""," config = config ? Y.Object(config) : {};"," transaction = io._create(config, id);"," method = config.method ? config.method.toUpperCase() : 'GET';"," sync = config.sync;"," data = config.data;",""," // Serialize an map object into a key-value string using"," // querystring-stringify-simple."," if ((Y.Lang.isObject(data) && !data.nodeType) && !transaction.upload) {"," data = Y.QueryString.stringify(data);"," }",""," if (config.form) {"," if (config.form.upload) {"," // This is a file upload transaction, calling"," // upload() in io-upload-iframe."," return io.upload(transaction, uri, config);"," } else {"," // Serialize HTML form data into a key-value string."," data = io._serialize(config.form, data);"," }"," }",""," if (data) {"," switch (method) {"," case 'GET':"," case 'HEAD':"," case 'DELETE':"," u = io._concat(u, data);"," data = '';"," break;"," case 'POST':"," case 'PUT':"," // If Content-Type is defined in the configuration object, or"," // or as a default header, it will be used instead of"," // 'application/x-www-form-urlencoded; charset=UTF-8'"," config.headers = Y.merge({"," 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'"," }, config.headers);"," break;"," }"," }",""," if (transaction.xdr) {"," // Route data to io-xdr module for flash and XDomainRequest."," return io.xdr(u, transaction, config);"," }"," else if (transaction.notify) {"," // Route data to custom transport"," return transaction.c.send(transaction, uri, config);"," }",""," if (!sync && !transaction.upload) {"," transaction.c.onreadystatechange = function() {"," io._rS(transaction, config);"," };"," }",""," try {"," // Determine if request is to be set as"," // synchronous or asynchronous."," transaction.c.open(method, u, !sync, config.username || null, config.password || null);"," io._setHeaders(transaction.c, config.headers || {});"," io.start(transaction, config);",""," // Will work only in browsers that implement the"," // Cross-Origin Resource Sharing draft."," if (config.xdr && config.xdr.credentials && SUPPORTS_CORS) {"," transaction.c.withCredentials = true;"," }",""," // Using \"null\" with HTTP POST will result in a request"," // with no Content-Length header defined."," transaction.c.send(data);",""," if (sync) {"," // Create a response object for synchronous transactions,"," // mixing id and arguments properties with the xhr"," // properties whitelist."," for (i = 0, len = XHR_PROPS.length; i < len; ++i) {"," response[XHR_PROPS[i]] = transaction.c[XHR_PROPS[i]];"," }",""," response.getAllResponseHeaders = function() {"," return transaction.c.getAllResponseHeaders();"," };",""," response.getResponseHeader = function(name) {"," return transaction.c.getResponseHeader(name);"," };",""," io.complete(transaction, config);"," io._result(transaction, config);",""," return response;"," }"," } catch(e) {"," if (transaction.xdr) {"," // This exception is usually thrown by browsers"," // that do not support XMLHttpRequest Level 2."," // Retry the request with the XDR transport set"," // to 'flash'. If the Flash transport is not"," // initialized or available, the transaction"," // will resolve to a transport error."," return io._retry(transaction, uri, config);"," } else {"," io.complete(transaction, config);"," io._result(transaction, config);"," }"," }",""," // If config.timeout is defined, and the request is standard XHR,"," // initialize timeout polling."," if (config.timeout) {"," io._startTimeout(transaction, config.timeout);"," }",""," return {"," id: transaction.id,"," abort: function() {"," return transaction.c ? io._abort(transaction, 'abort') : false;"," },"," isInProgress: function() {"," return transaction.c ? (transaction.c.readyState % 4) : false;"," },"," io: io"," };"," }","};","","/**","Method for initiating an ajax call. The first argument is the url end","point for the call. The second argument is an object to configure the","transaction and attach event subscriptions. The configuration object","supports the following properties:","","
","
method
","
HTTP method verb (e.g., GET or POST). If this property is not"," not defined, the default value will be GET.
","","
data
","
This is the name-value string that will be sent as the"," transaction data. If the request is HTTP GET, the data become"," part of querystring. If HTTP POST, the data are sent in the"," message body.
","","
xdr
","
Defines the transport to be used for cross-domain requests."," By setting this property, the transaction will use the specified"," transport instead of XMLHttpRequest. The properties of the"," transport object are:","
","
use
","
The transport to be used: 'flash' or 'native'
","
dataType
","
Set the value to 'XML' if that is the expected response"," content type.
","
","","
form
","
Form serialization configuration object. Its properties are:","
","
id
","
Node object or id of HTML form
","
useDisabled
","
`true` to also serialize disabled form field values"," (defaults to `false`)
","
","","
on
","
Assigns transaction event subscriptions. Available events are:","
","
start
","
Fires when a request is sent to a resource.
","
complete
","
Fires when the transaction is complete.
","
success
","
Fires when the HTTP response status is within the 2xx"," range.
","
failure
","
Fires when the HTTP response status is outside the 2xx"," range, if an exception occurs, if the transation is aborted,"," or if the transaction exceeds a configured `timeout`.
","
end
","
Fires at the conclusion of the transaction"," lifecycle, after `success` or `failure`.
","
","","

Callback functions for `start` and `end` receive the id of the"," transaction as a first argument. For `complete`, `success`, and"," `failure`, callbacks receive the id and the response object"," (usually the XMLHttpRequest instance). If the `arguments`"," property was included in the configuration object passed to"," `Y.io()`, the configured data will be passed to all callbacks as"," the last argument.

","
","","
sync
","
Pass `true` to make a same-domain transaction synchronous."," CAVEAT: This will negatively impact the user"," experience. Have a very good reason if you intend to use"," this.
","","
context
","
The \"`this'\" object for all configured event handlers. If a"," specific context is needed for individual callbacks, bind the"," callback to a context using `Y.bind()`.
","","
headers
","
Object map of transaction headers to send to the server. The"," object keys are the header names and the values are the header"," values.
","","
timeout
","
Millisecond threshold for the transaction before being"," automatically aborted.
","","
arguments
","
User-defined data passed to all registered event handlers."," This value is available as the second argument in the \"start\" and"," \"end\" event handlers. It is the third argument in the \"complete\","," \"success\", and \"failure\" event handlers. Be sure to quote"," this property name in the transaction configuration as"," \"arguments\" is a reserved word in JavaScript (e.g."," `Y.io({ ..., \"arguments\": stuff })`).
","
","","@method io","@static","@param {String} url qualified path to transaction resource.","@param {Object} config configuration object for the transaction.","@return {Object}","@for YUI","**/","Y.io = function(url, config) {"," // Calling IO through the static interface will use and reuse"," // an instance of IO."," var transaction = Y.io._map['io:0'] || new IO();"," return transaction.send.apply(transaction, [url, config]);","};","","/**","Method for setting and deleting IO HTTP headers to be sent with every","request.","","Hosted as a property on the `io` function (e.g. `Y.io.header`).","","@method header","@param {String} name HTTP header","@param {String} value HTTP header value","@static","**/","Y.io.header = function(name, value) {"," // Calling IO through the static interface will use and reuse"," // an instance of IO."," var transaction = Y.io._map['io:0'] || new IO();"," transaction.setHeader(name, value);","};","","Y.IO = IO;","// Map of all IO instances created.","Y.io._map = {};","var XHR = win && win.XMLHttpRequest,"," XDR = win && win.XDomainRequest,"," AX = win && win.ActiveXObject,",""," // Checks for the presence of the `withCredentials` in an XHR instance"," // object, which will be present if the environment supports CORS."," SUPPORTS_CORS = XHR && 'withCredentials' in (new XMLHttpRequest());","","","Y.mix(Y.IO, {"," /**"," * The ID of the default IO transport, defaults to `xhr`"," * @property _default"," * @type {String}"," * @static"," */"," _default: 'xhr',"," /**"," *"," * @method defaultTransport"," * @static"," * @param {String} [id] The transport to set as the default, if empty a new transport is created."," * @return {Object} The transport object with a `send` method"," */"," defaultTransport: function(id) {"," if (id) {"," Y.IO._default = id;"," } else {"," var o = {"," c: Y.IO.transports[Y.IO._default](),"," notify: Y.IO._default === 'xhr' ? false : true"," };"," return o;"," }"," },"," /**"," * An object hash of custom transports available to IO"," * @property transports"," * @type {Object}"," * @static"," */"," transports: {"," xhr: function () {"," return XHR ? new XMLHttpRequest() :"," AX ? new ActiveXObject('Microsoft.XMLHTTP') : null;"," },"," xdr: function () {"," return XDR ? new XDomainRequest() : null;"," },"," iframe: function () { return {}; },"," flash: null,"," nodejs: null"," },"," /**"," * Create a custom transport of type and return it's object"," * @method customTransport"," * @param {String} id The id of the transport to create."," * @static"," */"," customTransport: function(id) {"," var o = { c: Y.IO.transports[id]() };",""," o[(id === 'xdr' || id === 'flash') ? 'xdr' : 'notify'] = true;"," return o;"," }","});","","Y.mix(Y.IO.prototype, {"," /**"," * Fired from the notify method of the transport which in turn fires"," * the event on the IO object."," * @method notify"," * @param {String} event The name of the event"," * @param {Object} transaction The transaction object"," * @param {Object} config The configuration object for this transaction"," */"," notify: function(event, transaction, config) {"," var io = this;",""," switch (event) {"," case 'timeout':"," case 'abort':"," case 'transport error':"," transaction.c = { status: 0, statusText: event };"," event = 'failure';"," default:"," io[event].apply(io, [transaction, config]);"," }"," }","});","","","","","}, '@VERSION@', {\"requires\": [\"event-custom-base\", \"querystring-stringify-simple\"]});"]; -_yuitest_coverage["build/io-base/io-base.js"].lines = {"1":0,"11":0,"32":0,"33":0,"35":0,"36":0,"37":0,"40":0,"80":0,"82":0,"84":0,"85":0,"89":0,"92":0,"108":0,"117":0,"120":0,"125":0,"128":0,"129":0,"132":0,"133":0,"136":0,"137":0,"138":0,"139":0,"141":0,"142":0,"144":0,"145":0,"147":0,"151":0,"155":0,"156":0,"157":0,"158":0,"159":0,"160":0,"161":0,"162":0,"165":0,"169":0,"182":0,"189":0,"191":0,"192":0,"196":0,"206":0,"207":0,"208":0,"209":0,"212":0,"213":0,"215":0,"217":0,"218":0,"223":0,"225":0,"227":0,"228":0,"229":0,"230":0,"247":0,"266":0,"282":0,"283":0,"300":0,"301":0,"318":0,"319":0,"338":0,"339":0,"353":0,"354":0,"368":0,"369":0,"383":0,"384":0,"385":0,"398":0,"399":0,"411":0,"412":0,"414":0,"428":0,"429":0,"430":0,"431":0,"446":0,"448":0,"449":0,"461":0,"462":0,"477":0,"480":0,"481":0,"483":0,"487":0,"488":0,"490":0,"503":0,"505":0,"506":0,"507":0,"511":0,"512":0,"513":0,"527":0,"528":0,"529":0,"637":0,"642":0,"643":0,"644":0,"645":0,"646":0,"650":0,"651":0,"654":0,"655":0,"658":0,"661":0,"665":0,"666":0,"670":0,"671":0,"672":0,"678":0,"681":0,"685":0,"687":0,"689":0,"691":0,"694":0,"695":0,"696":0,"700":0,"703":0,"704":0,"705":0,"709":0,"710":0,"715":0,"717":0,"721":0,"722":0,"725":0,"726":0,"729":0,"730":0,"733":0,"734":0,"736":0,"739":0,"746":0,"748":0,"749":0,"755":0,"756":0,"759":0,"762":0,"765":0,"877":0,"880":0,"881":0,"895":0,"898":0,"899":0,"902":0,"904":0,"905":0,"914":0,"930":0,"931":0,"933":0,"937":0,"948":0,"952":0,"954":0,"965":0,"967":0,"968":0,"972":0,"982":0,"984":0,"988":0,"989":0,"991":0}; -_yuitest_coverage["build/io-base/io-base.js"].functions = {"IO:32":0,"_init:79":0,"notify:133":0,"onprogress:138":0,"onload:141":0,"onerror:144":0,"_create:107":0,"_destroy:154":0,"_evt:181":0,"start:242":0,"complete:259":0,"end:277":0,"success:294":0,"failure:312":0,"progress:332":0,"load:352":0,"error:367":0,"_retry:382":0,"_concat:397":0,"setHeader:410":0,"(anonymous 2):429":0,"_setHeaders:427":0,"(anonymous 3):448":0,"_startTimeout:445":0,"_clearTimeout:460":0,"_result:476":0,"(anonymous 4):511":0,"_rS:502":0,"_abort:526":0,"onreadystatechange:695":0,"getAllResponseHeaders:725":0,"getResponseHeader:729":0,"abort:761":0,"isInProgress:764":0,"send:636":0,"io:877":0,"header:895":0,"defaultTransport:929":0,"xhr:947":0,"xdr:951":0,"iframe:954":0,"customTransport:964":0,"notify:981":0,"(anonymous 1):1":0}; -_yuitest_coverage["build/io-base/io-base.js"].coveredLines = 188; +_yuitest_coverage["build/io-base/io-base.js"].code=["YUI.add('io-base', function (Y, NAME) {","","/**","Base IO functionality. Provides basic XHR transport support.","","@module io","@submodule io-base","@for IO","**/","","var // List of events that comprise the IO event lifecycle."," EVENTS = ['start', 'complete', 'end', 'success', 'failure', 'progress'],",""," // Whitelist of used XHR response object properties."," XHR_PROPS = ['status', 'statusText', 'responseText', 'responseXML'],",""," win = Y.config.win,"," uid = 0;","","/**","The IO class is a utility that brokers HTTP requests through a simplified","interface. Specifically, it allows JavaScript to make HTTP requests to","a resource without a page reload. The underlying transport for making","same-domain requests is the XMLHttpRequest object. IO can also use","Flash, if specified as a transport, for cross-domain requests.","","@class IO","@constructor","@param {Object} config Object of EventTarget's publish method configurations"," used to configure IO's events.","**/","function IO (config) {"," var io = this;",""," io._uid = 'io:' + uid++;"," io._init(config);"," Y.io._map[io._uid] = io;","}","","IO.prototype = {"," //--------------------------------------"," // Properties"," //--------------------------------------",""," /**"," * A counter that increments for each transaction."," *"," * @property _id"," * @private"," * @type {Number}"," */"," _id: 0,",""," /**"," * Object of IO HTTP headers sent with each transaction."," *"," * @property _headers"," * @private"," * @type {Object}"," */"," _headers: {"," 'X-Requested-With' : 'XMLHttpRequest'"," },",""," /**"," * Object that stores timeout values for any transaction with a defined"," * \"timeout\" configuration property."," *"," * @property _timeout"," * @private"," * @type {Object}"," */"," _timeout: {},",""," //--------------------------------------"," // Methods"," //--------------------------------------",""," _init: function(config) {"," var io = this, i, len;",""," io.cfg = config || {};",""," Y.augment(io, Y.EventTarget);"," for (i = 0, len = EVENTS.length; i < len; ++i) {"," // Publish IO global events with configurations, if any."," // IO global events are set to broadcast by default."," // These events use the \"io:\" namespace."," io.publish('io:' + EVENTS[i], Y.merge({ broadcast: 1 }, config));"," // Publish IO transaction events with configurations, if"," // any. These events use the \"io-trn:\" namespace."," io.publish('io-trn:' + EVENTS[i], config);"," }"," },",""," /**"," * Method that creates a unique transaction object for each request."," *"," * @method _create"," * @private"," * @param {Object} cfg Configuration object subset to determine if"," * the transaction is an XDR or file upload,"," * requiring an alternate transport."," * @param {Number} id Transaction id"," * @return {Object} The transaction object"," */"," _create: function(config, id) {"," var io = this,"," transaction = {"," id : Y.Lang.isNumber(id) ? id : io._id++,"," uid: io._uid"," },"," alt = config.xdr ? config.xdr.use : null,"," form = config.form && config.form.upload ? 'iframe' : null,"," use;",""," if (alt === 'native') {"," // Non-IE and IE >= 10 can use XHR level 2 and not rely on an"," // external transport."," alt = Y.UA.ie && !SUPPORTS_CORS ? 'xdr' : null;",""," // Prevent \"pre-flight\" OPTIONS request by removing the"," // `X-Requested-With` HTTP header from CORS requests. This header"," // can be added back on a per-request basis, if desired."," io.setHeader('X-Requested-With');"," }",""," use = alt || form;"," transaction = use ? Y.merge(Y.IO.customTransport(use), transaction) :"," Y.merge(Y.IO.defaultTransport(), transaction);",""," if (transaction.notify) {"," config.notify = function (e, t, c) { io.notify(e, t, c); };"," }",""," if (!use) {"," if (win && win.FormData && config.data instanceof win.FormData) {"," transaction.c.upload.onprogress = function (e) {"," io.progress(transaction, e, config);"," };"," transaction.c.onload = function (e) {"," io.load(transaction, e, config);"," };"," transaction.c.onerror = function (e) {"," io.error(transaction, e, config);"," };"," transaction.upload = true;"," }"," }",""," return transaction;"," },",""," _destroy: function(transaction) {"," if (win && !transaction.notify && !transaction.xdr) {"," if (XHR && !transaction.upload) {"," transaction.c.onreadystatechange = null;"," } else if (transaction.upload) {"," transaction.c.upload.onprogress = null;"," transaction.c.onload = null;"," transaction.c.onerror = null;"," } else if (Y.UA.ie && !transaction.e) {"," // IE, when using XMLHttpRequest as an ActiveX Object, will throw"," // a \"Type Mismatch\" error if the event handler is set to \"null\"."," transaction.c.abort();"," }"," }",""," transaction = transaction.c = null;"," },",""," /**"," * Method for creating and firing events."," *"," * @method _evt"," * @private"," * @param {String} eventName Event to be published."," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration data subset for event subscription."," */"," _evt: function(eventName, transaction, config) {"," var io = this, params,"," args = config['arguments'],"," emitFacade = io.cfg.emitFacade,"," globalEvent = \"io:\" + eventName,"," trnEvent = \"io-trn:\" + eventName;",""," // Workaround for #2532107"," this.detach(trnEvent);",""," if (transaction.e) {"," transaction.c = { status: 0, statusText: transaction.e };"," }",""," // Fire event with parameters or an Event Facade."," params = [ emitFacade ?"," {"," id: transaction.id,"," data: transaction.c,"," cfg: config,"," 'arguments': args"," } :"," transaction.id"," ];",""," if (!emitFacade) {"," if (eventName === EVENTS[0] || eventName === EVENTS[2]) {"," if (args) {"," params.push(args);"," }"," } else {"," if (transaction.evt) {"," params.push(transaction.evt);"," } else {"," params.push(transaction.c);"," }"," if (args) {"," params.push(args);"," }"," }"," }",""," params.unshift(globalEvent);"," // Fire global events."," io.fire.apply(io, params);"," // Fire transaction events, if receivers are defined."," if (config.on) {"," params[0] = trnEvent;"," io.once(trnEvent, config.on[eventName], config.context || Y);"," io.fire.apply(io, params);"," }"," },",""," /**"," * Fires event \"io:start\" and creates, fires a transaction-specific"," * start event, if `config.on.start` is defined."," *"," * @method start"," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration object for the transaction."," */"," start: function(transaction, config) {"," /**"," * Signals the start of an IO request."," * @event io:start"," */"," this._evt(EVENTS[0], transaction, config);"," },",""," /**"," * Fires event \"io:complete\" and creates, fires a"," * transaction-specific \"complete\" event, if config.on.complete is"," * defined."," *"," * @method complete"," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration object for the transaction."," */"," complete: function(transaction, config) {"," /**"," * Signals the completion of the request-response phase of a"," * transaction. Response status and data are accessible, if"," * available, in this event."," * @event io:complete"," */"," this._evt(EVENTS[1], transaction, config);"," },",""," /**"," * Fires event \"io:end\" and creates, fires a transaction-specific \"end\""," * event, if config.on.end is defined."," *"," * @method end"," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration object for the transaction."," */"," end: function(transaction, config) {"," /**"," * Signals the end of the transaction lifecycle."," * @event io:end"," */"," this._evt(EVENTS[2], transaction, config);"," this._destroy(transaction);"," },",""," /**"," * Fires event \"io:success\" and creates, fires a transaction-specific"," * \"success\" event, if config.on.success is defined."," *"," * @method success"," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration object for the transaction."," */"," success: function(transaction, config) {"," /**"," * Signals an HTTP response with status in the 2xx range."," * Fires after io:complete."," * @event io:success"," */"," this._evt(EVENTS[3], transaction, config);"," this.end(transaction, config);"," },",""," /**"," * Fires event \"io:failure\" and creates, fires a transaction-specific"," * \"failure\" event, if config.on.failure is defined."," *"," * @method failure"," * @param {Object} transaction Transaction object."," * @param {Object} config Configuration object for the transaction."," */"," failure: function(transaction, config) {"," /**"," * Signals an HTTP response with status outside of the 2xx range."," * Fires after io:complete."," * @event io:failure"," */"," this._evt(EVENTS[4], transaction, config);"," this.end(transaction, config);"," },",""," /**"," * Fires event \"io:progress\" and creates, fires a transaction-specific"," * \"progress\" event -- for XMLHttpRequest file upload -- if"," * config.on.progress is defined."," *"," * @method progress"," * @param {Object} transaction Transaction object."," * @param {Object} progress event."," * @param {Object} config Configuration object for the transaction."," */"," progress: function(transaction, e, config) {"," /**"," * Signals the interactive state during a file upload transaction."," * This event fires after io:start and before io:complete."," * @event io:progress"," */"," transaction.evt = e;"," this._evt(EVENTS[5], transaction, config);"," },",""," /**"," * Fires event \"io:complete\" and creates, fires a transaction-specific"," * \"complete\" event -- for XMLHttpRequest file upload -- if"," * config.on.complete is defined."," *"," * @method load"," * @param {Object} transaction Transaction object."," * @param {Object} load event."," * @param {Object} config Configuration object for the transaction."," */"," load: function (transaction, e, config) {"," transaction.evt = e.target;"," this._evt(EVENTS[1], transaction, config);"," },",""," /**"," * Fires event \"io:failure\" and creates, fires a transaction-specific"," * \"failure\" event -- for XMLHttpRequest file upload -- if"," * config.on.failure is defined."," *"," * @method error"," * @param {Object} transaction Transaction object."," * @param {Object} error event."," * @param {Object} config Configuration object for the transaction."," */"," error: function (transaction, e, config) {"," transaction.evt = e;"," this._evt(EVENTS[4], transaction, config);"," },",""," /**"," * Retry an XDR transaction, using the Flash tranport, if the native"," * transport fails."," *"," * @method _retry"," * @private"," * @param {Object} transaction Transaction object."," * @param {String} uri Qualified path to transaction resource."," * @param {Object} config Configuration object for the transaction."," */"," _retry: function(transaction, uri, config) {"," this._destroy(transaction);"," config.xdr.use = 'flash';"," return this.send(uri, config, transaction.id);"," },",""," /**"," * Method that concatenates string data for HTTP GET transactions."," *"," * @method _concat"," * @private"," * @param {String} uri URI or root data."," * @param {String} data Data to be concatenated onto URI."," * @return {String}"," */"," _concat: function(uri, data) {"," uri += (uri.indexOf('?') === -1 ? '?' : '&') + data;"," return uri;"," },",""," /**"," * Stores default client headers for all transactions. If a label is"," * passed with no value argument, the header will be deleted."," *"," * @method setHeader"," * @param {String} name HTTP header"," * @param {String} value HTTP header value"," */"," setHeader: function(name, value) {"," if (value) {"," this._headers[name] = value;"," } else {"," delete this._headers[name];"," }"," },",""," /**"," * Method that sets all HTTP headers to be sent in a transaction."," *"," * @method _setHeaders"," * @private"," * @param {Object} transaction - XHR instance for the specific transaction."," * @param {Object} headers - HTTP headers for the specific transaction, as"," * defined in the configuration object passed to YUI.io()."," */"," _setHeaders: function(transaction, headers) {"," headers = Y.merge(this._headers, headers);"," Y.Object.each(headers, function(value, name) {"," if (value !== 'disable') {"," transaction.setRequestHeader(name, headers[name]);"," }"," });"," },",""," /**"," * Starts timeout count if the configuration object has a defined"," * timeout property."," *"," * @method _startTimeout"," * @private"," * @param {Object} transaction Transaction object generated by _create()."," * @param {Object} timeout Timeout in milliseconds."," */"," _startTimeout: function(transaction, timeout) {"," var io = this;",""," io._timeout[transaction.id] = setTimeout(function() {"," io._abort(transaction, 'timeout');"," }, timeout);"," },",""," /**"," * Clears the timeout interval started by _startTimeout()."," *"," * @method _clearTimeout"," * @private"," * @param {Number} id - Transaction id."," */"," _clearTimeout: function(id) {"," clearTimeout(this._timeout[id]);"," delete this._timeout[id];"," },",""," /**"," * Method that determines if a transaction response qualifies as success"," * or failure, based on the response HTTP status code, and fires the"," * appropriate success or failure events."," *"," * @method _result"," * @private"," * @static"," * @param {Object} transaction Transaction object generated by _create()."," * @param {Object} config Configuration object passed to io()."," */"," _result: function(transaction, config) {"," var status;"," // Firefox will throw an exception if attempting to access"," // an XHR object's status property, after a request is aborted."," try {"," status = transaction.c.status;"," } catch(e) {"," status = 0;"," }",""," // IE reports HTTP 204 as HTTP 1223."," if (status >= 200 && status < 300 || status === 304 || status === 1223) {"," this.success(transaction, config);"," } else {"," this.failure(transaction, config);"," }"," },",""," /**"," * Event handler bound to onreadystatechange."," *"," * @method _rS"," * @private"," * @param {Object} transaction Transaction object generated by _create()."," * @param {Object} config Configuration object passed to YUI.io()."," */"," _rS: function(transaction, config) {"," var io = this;",""," if (transaction.c.readyState === 4) {"," if (config.timeout) {"," io._clearTimeout(transaction.id);"," }",""," // Yield in the event of request timeout or abort."," setTimeout(function() {"," io.complete(transaction, config);"," io._result(transaction, config);"," }, 0);"," }"," },",""," /**"," * Terminates a transaction due to an explicit abort or timeout."," *"," * @method _abort"," * @private"," * @param {Object} transaction Transaction object generated by _create()."," * @param {String} type Identifies timed out or aborted transaction."," */"," _abort: function(transaction, type) {"," if (transaction && transaction.c) {"," transaction.e = type;"," transaction.c.abort();"," }"," },",""," /**"," * Requests a transaction. `send()` is implemented as `Y.io()`. Each"," * transaction may include a configuration object. Its properties are:"," *"," *
"," *
method
"," *
HTTP method verb (e.g., GET or POST). If this property is not"," * not defined, the default value will be GET.
"," *"," *
data
"," *
This is the name-value string that will be sent as the"," * transaction data. If the request is HTTP GET, the data become"," * part of querystring. If HTTP POST, the data are sent in the"," * message body.
"," *"," *
xdr
"," *
Defines the transport to be used for cross-domain requests."," * By setting this property, the transaction will use the specified"," * transport instead of XMLHttpRequest. The properties of the"," * transport object are:"," *
"," *
use
"," *
The transport to be used: 'flash' or 'native'
"," *
dataType
"," *
Set the value to 'XML' if that is the expected response"," * content type.
"," *
"," *"," *
form
"," *
Form serialization configuration object. Its properties are:"," *
"," *
id
"," *
Node object or id of HTML form
"," *
useDisabled
"," *
`true` to also serialize disabled form field values"," * (defaults to `false`)
"," *
"," *"," *
on
"," *
Assigns transaction event subscriptions. Available events are:"," *
"," *
start
"," *
Fires when a request is sent to a resource.
"," *
complete
"," *
Fires when the transaction is complete.
"," *
success
"," *
Fires when the HTTP response status is within the 2xx"," * range.
"," *
failure
"," *
Fires when the HTTP response status is outside the 2xx"," * range, if an exception occurs, if the transation is aborted,"," * or if the transaction exceeds a configured `timeout`.
"," *
end
"," *
Fires at the conclusion of the transaction"," * lifecycle, after `success` or `failure`.
"," *
"," *"," *

Callback functions for `start` and `end` receive the id of the"," * transaction as a first argument. For `complete`, `success`, and"," * `failure`, callbacks receive the id and the response object"," * (usually the XMLHttpRequest instance). If the `arguments`"," * property was included in the configuration object passed to"," * `Y.io()`, the configured data will be passed to all callbacks as"," * the last argument.

"," *
"," *"," *
sync
"," *
Pass `true` to make a same-domain transaction synchronous."," * CAVEAT: This will negatively impact the user"," * experience. Have a very good reason if you intend to use"," * this.
"," *"," *
context
"," *
The \"`this'\" object for all configured event handlers. If a"," * specific context is needed for individual callbacks, bind the"," * callback to a context using `Y.bind()`.
"," *"," *
headers
"," *
Object map of transaction headers to send to the server. The"," * object keys are the header names and the values are the header"," * values.
"," *"," *
timeout
"," *
Millisecond threshold for the transaction before being"," * automatically aborted.
"," *"," *
arguments
"," *
User-defined data passed to all registered event handlers."," * This value is available as the second argument in the \"start\" and"," * \"end\" event handlers. It is the third argument in the \"complete\","," * \"success\", and \"failure\" event handlers. Be sure to quote"," * this property name in the transaction configuration as"," * \"arguments\" is a reserved word in JavaScript (e.g."," * `Y.io({ ..., \"arguments\": stuff })`).
"," *
"," *"," * @method send"," * @public"," * @param {String} uri Qualified path to transaction resource."," * @param {Object} config Configuration object for the transaction."," * @param {Number} id Transaction id, if already set."," * @return {Object}"," */"," send: function(uri, config, id) {"," var transaction, method, i, len, sync, data,"," io = this,"," u = uri,"," response = {};",""," config = config ? Y.Object(config) : {};"," transaction = io._create(config, id);"," method = config.method ? config.method.toUpperCase() : 'GET';"," sync = config.sync;"," data = config.data;",""," // Serialize a map object into a key-value string using"," // querystring-stringify-simple."," if ((Y.Lang.isObject(data) && !data.nodeType) && !transaction.upload) {"," if (Y.QueryString && Y.QueryString.stringify) {"," config.data = data = Y.QueryString.stringify(data);"," } else {"," }"," }",""," if (config.form) {"," if (config.form.upload) {"," // This is a file upload transaction, calling"," // upload() in io-upload-iframe."," return io.upload(transaction, uri, config);"," } else {"," // Serialize HTML form data into a key-value string."," data = io._serialize(config.form, data);"," }"," }",""," if (data) {"," switch (method) {"," case 'GET':"," case 'HEAD':"," case 'DELETE':"," u = io._concat(u, data);"," data = '';"," break;"," case 'POST':"," case 'PUT':"," // If Content-Type is defined in the configuration object, or"," // or as a default header, it will be used instead of"," // 'application/x-www-form-urlencoded; charset=UTF-8'"," config.headers = Y.merge({"," 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'"," }, config.headers);"," break;"," }"," }",""," if (transaction.xdr) {"," // Route data to io-xdr module for flash and XDomainRequest."," return io.xdr(u, transaction, config);"," }"," else if (transaction.notify) {"," // Route data to custom transport"," return transaction.c.send(transaction, uri, config);"," }",""," if (!sync && !transaction.upload) {"," transaction.c.onreadystatechange = function() {"," io._rS(transaction, config);"," };"," }",""," try {"," // Determine if request is to be set as"," // synchronous or asynchronous."," transaction.c.open(method, u, !sync, config.username || null, config.password || null);"," io._setHeaders(transaction.c, config.headers || {});"," io.start(transaction, config);",""," // Will work only in browsers that implement the"," // Cross-Origin Resource Sharing draft."," if (config.xdr && config.xdr.credentials && SUPPORTS_CORS) {"," transaction.c.withCredentials = true;"," }",""," // Using \"null\" with HTTP POST will result in a request"," // with no Content-Length header defined."," transaction.c.send(data);",""," if (sync) {"," // Create a response object for synchronous transactions,"," // mixing id and arguments properties with the xhr"," // properties whitelist."," for (i = 0, len = XHR_PROPS.length; i < len; ++i) {"," response[XHR_PROPS[i]] = transaction.c[XHR_PROPS[i]];"," }",""," response.getAllResponseHeaders = function() {"," return transaction.c.getAllResponseHeaders();"," };",""," response.getResponseHeader = function(name) {"," return transaction.c.getResponseHeader(name);"," };",""," io.complete(transaction, config);"," io._result(transaction, config);",""," return response;"," }"," } catch(e) {"," if (transaction.xdr) {"," // This exception is usually thrown by browsers"," // that do not support XMLHttpRequest Level 2."," // Retry the request with the XDR transport set"," // to 'flash'. If the Flash transport is not"," // initialized or available, the transaction"," // will resolve to a transport error."," return io._retry(transaction, uri, config);"," } else {"," io.complete(transaction, config);"," io._result(transaction, config);"," }"," }",""," // If config.timeout is defined, and the request is standard XHR,"," // initialize timeout polling."," if (config.timeout) {"," io._startTimeout(transaction, config.timeout);"," }",""," return {"," id: transaction.id,"," abort: function() {"," return transaction.c ? io._abort(transaction, 'abort') : false;"," },"," isInProgress: function() {"," return transaction.c ? (transaction.c.readyState % 4) : false;"," },"," io: io"," };"," }","};","","/**","Method for initiating an ajax call. The first argument is the url end","point for the call. The second argument is an object to configure the","transaction and attach event subscriptions. The configuration object","supports the following properties:","","
","
method
","
HTTP method verb (e.g., GET or POST). If this property is not"," not defined, the default value will be GET.
","","
data
","
This is the name-value string that will be sent as the"," transaction data. If the request is HTTP GET, the data become"," part of querystring. If HTTP POST, the data are sent in the"," message body.
","","
xdr
","
Defines the transport to be used for cross-domain requests."," By setting this property, the transaction will use the specified"," transport instead of XMLHttpRequest. The properties of the"," transport object are:","
","
use
","
The transport to be used: 'flash' or 'native'
","
dataType
","
Set the value to 'XML' if that is the expected response"," content type.
","
","","
form
","
Form serialization configuration object. Its properties are:","
","
id
","
Node object or id of HTML form
","
useDisabled
","
`true` to also serialize disabled form field values"," (defaults to `false`)
","
","","
on
","
Assigns transaction event subscriptions. Available events are:","
","
start
","
Fires when a request is sent to a resource.
","
complete
","
Fires when the transaction is complete.
","
success
","
Fires when the HTTP response status is within the 2xx"," range.
","
failure
","
Fires when the HTTP response status is outside the 2xx"," range, if an exception occurs, if the transation is aborted,"," or if the transaction exceeds a configured `timeout`.
","
end
","
Fires at the conclusion of the transaction"," lifecycle, after `success` or `failure`.
","
","","

Callback functions for `start` and `end` receive the id of the"," transaction as a first argument. For `complete`, `success`, and"," `failure`, callbacks receive the id and the response object"," (usually the XMLHttpRequest instance). If the `arguments`"," property was included in the configuration object passed to"," `Y.io()`, the configured data will be passed to all callbacks as"," the last argument.

","
","","
sync
","
Pass `true` to make a same-domain transaction synchronous."," CAVEAT: This will negatively impact the user"," experience. Have a very good reason if you intend to use"," this.
","","
context
","
The \"`this'\" object for all configured event handlers. If a"," specific context is needed for individual callbacks, bind the"," callback to a context using `Y.bind()`.
","","
headers
","
Object map of transaction headers to send to the server. The"," object keys are the header names and the values are the header"," values.
","","
timeout
","
Millisecond threshold for the transaction before being"," automatically aborted.
","","
arguments
","
User-defined data passed to all registered event handlers."," This value is available as the second argument in the \"start\" and"," \"end\" event handlers. It is the third argument in the \"complete\","," \"success\", and \"failure\" event handlers. Be sure to quote"," this property name in the transaction configuration as"," \"arguments\" is a reserved word in JavaScript (e.g."," `Y.io({ ..., \"arguments\": stuff })`).
","
","","@method io","@static","@param {String} url qualified path to transaction resource.","@param {Object} config configuration object for the transaction.","@return {Object}","@for YUI","**/","Y.io = function(url, config) {"," // Calling IO through the static interface will use and reuse"," // an instance of IO."," var transaction = Y.io._map['io:0'] || new IO();"," return transaction.send.apply(transaction, [url, config]);","};","","/**","Method for setting and deleting IO HTTP headers to be sent with every","request.","","Hosted as a property on the `io` function (e.g. `Y.io.header`).","","@method header","@param {String} name HTTP header","@param {String} value HTTP header value","@static","**/","Y.io.header = function(name, value) {"," // Calling IO through the static interface will use and reuse"," // an instance of IO."," var transaction = Y.io._map['io:0'] || new IO();"," transaction.setHeader(name, value);","};","","Y.IO = IO;","// Map of all IO instances created.","Y.io._map = {};","var XHR = win && win.XMLHttpRequest,"," XDR = win && win.XDomainRequest,"," AX = win && win.ActiveXObject,",""," // Checks for the presence of the `withCredentials` in an XHR instance"," // object, which will be present if the environment supports CORS."," SUPPORTS_CORS = XHR && 'withCredentials' in (new XMLHttpRequest());","","","Y.mix(Y.IO, {"," /**"," * The ID of the default IO transport, defaults to `xhr`"," * @property _default"," * @type {String}"," * @static"," */"," _default: 'xhr',"," /**"," *"," * @method defaultTransport"," * @static"," * @param {String} [id] The transport to set as the default, if empty a new transport is created."," * @return {Object} The transport object with a `send` method"," */"," defaultTransport: function(id) {"," if (id) {"," Y.IO._default = id;"," } else {"," var o = {"," c: Y.IO.transports[Y.IO._default](),"," notify: Y.IO._default === 'xhr' ? false : true"," };"," return o;"," }"," },"," /**"," * An object hash of custom transports available to IO"," * @property transports"," * @type {Object}"," * @static"," */"," transports: {"," xhr: function () {"," return XHR ? new XMLHttpRequest() :"," AX ? new ActiveXObject('Microsoft.XMLHTTP') : null;"," },"," xdr: function () {"," return XDR ? new XDomainRequest() : null;"," },"," iframe: function () { return {}; },"," flash: null,"," nodejs: null"," },"," /**"," * Create a custom transport of type and return it's object"," * @method customTransport"," * @param {String} id The id of the transport to create."," * @static"," */"," customTransport: function(id) {"," var o = { c: Y.IO.transports[id]() };",""," o[(id === 'xdr' || id === 'flash') ? 'xdr' : 'notify'] = true;"," return o;"," }","});","","Y.mix(Y.IO.prototype, {"," /**"," * Fired from the notify method of the transport which in turn fires"," * the event on the IO object."," * @method notify"," * @param {String} event The name of the event"," * @param {Object} transaction The transaction object"," * @param {Object} config The configuration object for this transaction"," */"," notify: function(event, transaction, config) {"," var io = this;",""," switch (event) {"," case 'timeout':"," case 'abort':"," case 'transport error':"," transaction.c = { status: 0, statusText: event };"," event = 'failure';"," default:"," io[event].apply(io, [transaction, config]);"," }"," }","});","","","","","}, '@VERSION@', {\"requires\": [\"event-custom-base\", \"querystring-stringify-simple\"]});"]; +_yuitest_coverage["build/io-base/io-base.js"].lines = {"1":0,"11":0,"32":0,"33":0,"35":0,"36":0,"37":0,"40":0,"80":0,"82":0,"84":0,"85":0,"89":0,"92":0,"108":0,"117":0,"120":0,"125":0,"128":0,"129":0,"132":0,"133":0,"136":0,"137":0,"138":0,"139":0,"141":0,"142":0,"144":0,"145":0,"147":0,"151":0,"155":0,"156":0,"157":0,"158":0,"159":0,"160":0,"161":0,"162":0,"165":0,"169":0,"182":0,"189":0,"191":0,"192":0,"196":0,"206":0,"207":0,"208":0,"209":0,"212":0,"213":0,"215":0,"217":0,"218":0,"223":0,"225":0,"227":0,"228":0,"229":0,"230":0,"247":0,"266":0,"282":0,"283":0,"300":0,"301":0,"318":0,"319":0,"338":0,"339":0,"353":0,"354":0,"368":0,"369":0,"383":0,"384":0,"385":0,"398":0,"399":0,"411":0,"412":0,"414":0,"428":0,"429":0,"430":0,"431":0,"446":0,"448":0,"449":0,"461":0,"462":0,"477":0,"480":0,"481":0,"483":0,"487":0,"488":0,"490":0,"503":0,"505":0,"506":0,"507":0,"511":0,"512":0,"513":0,"527":0,"528":0,"529":0,"637":0,"642":0,"643":0,"644":0,"645":0,"646":0,"650":0,"651":0,"652":0,"657":0,"658":0,"661":0,"664":0,"668":0,"669":0,"673":0,"674":0,"675":0,"681":0,"684":0,"688":0,"690":0,"692":0,"694":0,"697":0,"698":0,"699":0,"703":0,"706":0,"707":0,"708":0,"712":0,"713":0,"718":0,"720":0,"724":0,"725":0,"728":0,"729":0,"732":0,"733":0,"736":0,"737":0,"739":0,"742":0,"749":0,"751":0,"752":0,"758":0,"759":0,"762":0,"765":0,"768":0,"880":0,"883":0,"884":0,"898":0,"901":0,"902":0,"905":0,"907":0,"908":0,"917":0,"933":0,"934":0,"936":0,"940":0,"951":0,"955":0,"957":0,"968":0,"970":0,"971":0,"975":0,"985":0,"987":0,"991":0,"992":0,"994":0}; +_yuitest_coverage["build/io-base/io-base.js"].functions = {"IO:32":0,"_init:79":0,"notify:133":0,"onprogress:138":0,"onload:141":0,"onerror:144":0,"_create:107":0,"_destroy:154":0,"_evt:181":0,"start:242":0,"complete:259":0,"end:277":0,"success:294":0,"failure:312":0,"progress:332":0,"load:352":0,"error:367":0,"_retry:382":0,"_concat:397":0,"setHeader:410":0,"(anonymous 2):429":0,"_setHeaders:427":0,"(anonymous 3):448":0,"_startTimeout:445":0,"_clearTimeout:460":0,"_result:476":0,"(anonymous 4):511":0,"_rS:502":0,"_abort:526":0,"onreadystatechange:698":0,"getAllResponseHeaders:728":0,"getResponseHeader:732":0,"abort:764":0,"isInProgress:767":0,"send:636":0,"io:880":0,"header:898":0,"defaultTransport:932":0,"xhr:950":0,"xdr:954":0,"iframe:957":0,"customTransport:967":0,"notify:984":0,"(anonymous 1):1":0}; +_yuitest_coverage["build/io-base/io-base.js"].coveredLines = 189; _yuitest_coverage["build/io-base/io-base.js"].coveredFunctions = 44; _yuitest_coverline("build/io-base/io-base.js", 1); YUI.add('io-base', function (Y, NAME) { @@ -825,138 +825,142 @@ sync = config.sync; _yuitest_coverline("build/io-base/io-base.js", 646); data = config.data; - // Serialize an map object into a key-value string using + // Serialize a map object into a key-value string using // querystring-stringify-simple. _yuitest_coverline("build/io-base/io-base.js", 650); if ((Y.Lang.isObject(data) && !data.nodeType) && !transaction.upload) { _yuitest_coverline("build/io-base/io-base.js", 651); -data = Y.QueryString.stringify(data); +if (Y.QueryString && Y.QueryString.stringify) { + _yuitest_coverline("build/io-base/io-base.js", 652); +config.data = data = Y.QueryString.stringify(data); + } else { + } } - _yuitest_coverline("build/io-base/io-base.js", 654); + _yuitest_coverline("build/io-base/io-base.js", 657); if (config.form) { - _yuitest_coverline("build/io-base/io-base.js", 655); + _yuitest_coverline("build/io-base/io-base.js", 658); if (config.form.upload) { // This is a file upload transaction, calling // upload() in io-upload-iframe. - _yuitest_coverline("build/io-base/io-base.js", 658); + _yuitest_coverline("build/io-base/io-base.js", 661); return io.upload(transaction, uri, config); } else { // Serialize HTML form data into a key-value string. - _yuitest_coverline("build/io-base/io-base.js", 661); + _yuitest_coverline("build/io-base/io-base.js", 664); data = io._serialize(config.form, data); } } - _yuitest_coverline("build/io-base/io-base.js", 665); + _yuitest_coverline("build/io-base/io-base.js", 668); if (data) { - _yuitest_coverline("build/io-base/io-base.js", 666); + _yuitest_coverline("build/io-base/io-base.js", 669); switch (method) { case 'GET': case 'HEAD': case 'DELETE': - _yuitest_coverline("build/io-base/io-base.js", 670); + _yuitest_coverline("build/io-base/io-base.js", 673); u = io._concat(u, data); - _yuitest_coverline("build/io-base/io-base.js", 671); + _yuitest_coverline("build/io-base/io-base.js", 674); data = ''; - _yuitest_coverline("build/io-base/io-base.js", 672); + _yuitest_coverline("build/io-base/io-base.js", 675); break; case 'POST': case 'PUT': // If Content-Type is defined in the configuration object, or // or as a default header, it will be used instead of // 'application/x-www-form-urlencoded; charset=UTF-8' - _yuitest_coverline("build/io-base/io-base.js", 678); + _yuitest_coverline("build/io-base/io-base.js", 681); config.headers = Y.merge({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, config.headers); - _yuitest_coverline("build/io-base/io-base.js", 681); + _yuitest_coverline("build/io-base/io-base.js", 684); break; } } - _yuitest_coverline("build/io-base/io-base.js", 685); + _yuitest_coverline("build/io-base/io-base.js", 688); if (transaction.xdr) { // Route data to io-xdr module for flash and XDomainRequest. - _yuitest_coverline("build/io-base/io-base.js", 687); + _yuitest_coverline("build/io-base/io-base.js", 690); return io.xdr(u, transaction, config); } - else {_yuitest_coverline("build/io-base/io-base.js", 689); + else {_yuitest_coverline("build/io-base/io-base.js", 692); if (transaction.notify) { // Route data to custom transport - _yuitest_coverline("build/io-base/io-base.js", 691); + _yuitest_coverline("build/io-base/io-base.js", 694); return transaction.c.send(transaction, uri, config); }} - _yuitest_coverline("build/io-base/io-base.js", 694); + _yuitest_coverline("build/io-base/io-base.js", 697); if (!sync && !transaction.upload) { - _yuitest_coverline("build/io-base/io-base.js", 695); + _yuitest_coverline("build/io-base/io-base.js", 698); transaction.c.onreadystatechange = function() { - _yuitest_coverfunc("build/io-base/io-base.js", "onreadystatechange", 695); -_yuitest_coverline("build/io-base/io-base.js", 696); + _yuitest_coverfunc("build/io-base/io-base.js", "onreadystatechange", 698); +_yuitest_coverline("build/io-base/io-base.js", 699); io._rS(transaction, config); }; } - _yuitest_coverline("build/io-base/io-base.js", 700); + _yuitest_coverline("build/io-base/io-base.js", 703); try { // Determine if request is to be set as // synchronous or asynchronous. - _yuitest_coverline("build/io-base/io-base.js", 703); + _yuitest_coverline("build/io-base/io-base.js", 706); transaction.c.open(method, u, !sync, config.username || null, config.password || null); - _yuitest_coverline("build/io-base/io-base.js", 704); + _yuitest_coverline("build/io-base/io-base.js", 707); io._setHeaders(transaction.c, config.headers || {}); - _yuitest_coverline("build/io-base/io-base.js", 705); + _yuitest_coverline("build/io-base/io-base.js", 708); io.start(transaction, config); // Will work only in browsers that implement the // Cross-Origin Resource Sharing draft. - _yuitest_coverline("build/io-base/io-base.js", 709); + _yuitest_coverline("build/io-base/io-base.js", 712); if (config.xdr && config.xdr.credentials && SUPPORTS_CORS) { - _yuitest_coverline("build/io-base/io-base.js", 710); + _yuitest_coverline("build/io-base/io-base.js", 713); transaction.c.withCredentials = true; } // Using "null" with HTTP POST will result in a request // with no Content-Length header defined. - _yuitest_coverline("build/io-base/io-base.js", 715); + _yuitest_coverline("build/io-base/io-base.js", 718); transaction.c.send(data); - _yuitest_coverline("build/io-base/io-base.js", 717); + _yuitest_coverline("build/io-base/io-base.js", 720); if (sync) { // Create a response object for synchronous transactions, // mixing id and arguments properties with the xhr // properties whitelist. - _yuitest_coverline("build/io-base/io-base.js", 721); + _yuitest_coverline("build/io-base/io-base.js", 724); for (i = 0, len = XHR_PROPS.length; i < len; ++i) { - _yuitest_coverline("build/io-base/io-base.js", 722); + _yuitest_coverline("build/io-base/io-base.js", 725); response[XHR_PROPS[i]] = transaction.c[XHR_PROPS[i]]; } - _yuitest_coverline("build/io-base/io-base.js", 725); + _yuitest_coverline("build/io-base/io-base.js", 728); response.getAllResponseHeaders = function() { - _yuitest_coverfunc("build/io-base/io-base.js", "getAllResponseHeaders", 725); -_yuitest_coverline("build/io-base/io-base.js", 726); + _yuitest_coverfunc("build/io-base/io-base.js", "getAllResponseHeaders", 728); +_yuitest_coverline("build/io-base/io-base.js", 729); return transaction.c.getAllResponseHeaders(); }; - _yuitest_coverline("build/io-base/io-base.js", 729); + _yuitest_coverline("build/io-base/io-base.js", 732); response.getResponseHeader = function(name) { - _yuitest_coverfunc("build/io-base/io-base.js", "getResponseHeader", 729); -_yuitest_coverline("build/io-base/io-base.js", 730); + _yuitest_coverfunc("build/io-base/io-base.js", "getResponseHeader", 732); +_yuitest_coverline("build/io-base/io-base.js", 733); return transaction.c.getResponseHeader(name); }; - _yuitest_coverline("build/io-base/io-base.js", 733); + _yuitest_coverline("build/io-base/io-base.js", 736); io.complete(transaction, config); - _yuitest_coverline("build/io-base/io-base.js", 734); + _yuitest_coverline("build/io-base/io-base.js", 737); io._result(transaction, config); - _yuitest_coverline("build/io-base/io-base.js", 736); + _yuitest_coverline("build/io-base/io-base.js", 739); return response; } } catch(e) { - _yuitest_coverline("build/io-base/io-base.js", 739); + _yuitest_coverline("build/io-base/io-base.js", 742); if (transaction.xdr) { // This exception is usually thrown by browsers // that do not support XMLHttpRequest Level 2. @@ -964,35 +968,35 @@ if (transaction.xdr) { // to 'flash'. If the Flash transport is not // initialized or available, the transaction // will resolve to a transport error. - _yuitest_coverline("build/io-base/io-base.js", 746); + _yuitest_coverline("build/io-base/io-base.js", 749); return io._retry(transaction, uri, config); } else { - _yuitest_coverline("build/io-base/io-base.js", 748); + _yuitest_coverline("build/io-base/io-base.js", 751); io.complete(transaction, config); - _yuitest_coverline("build/io-base/io-base.js", 749); + _yuitest_coverline("build/io-base/io-base.js", 752); io._result(transaction, config); } } // If config.timeout is defined, and the request is standard XHR, // initialize timeout polling. - _yuitest_coverline("build/io-base/io-base.js", 755); + _yuitest_coverline("build/io-base/io-base.js", 758); if (config.timeout) { - _yuitest_coverline("build/io-base/io-base.js", 756); + _yuitest_coverline("build/io-base/io-base.js", 759); io._startTimeout(transaction, config.timeout); } - _yuitest_coverline("build/io-base/io-base.js", 759); + _yuitest_coverline("build/io-base/io-base.js", 762); return { id: transaction.id, abort: function() { - _yuitest_coverfunc("build/io-base/io-base.js", "abort", 761); -_yuitest_coverline("build/io-base/io-base.js", 762); + _yuitest_coverfunc("build/io-base/io-base.js", "abort", 764); +_yuitest_coverline("build/io-base/io-base.js", 765); return transaction.c ? io._abort(transaction, 'abort') : false; }, isInProgress: function() { - _yuitest_coverfunc("build/io-base/io-base.js", "isInProgress", 764); -_yuitest_coverline("build/io-base/io-base.js", 765); + _yuitest_coverfunc("build/io-base/io-base.js", "isInProgress", 767); +_yuitest_coverline("build/io-base/io-base.js", 768); return transaction.c ? (transaction.c.readyState % 4) : false; }, io: io @@ -1105,14 +1109,14 @@ supports the following properties: @return {Object} @for YUI **/ -_yuitest_coverline("build/io-base/io-base.js", 877); +_yuitest_coverline("build/io-base/io-base.js", 880); Y.io = function(url, config) { // Calling IO through the static interface will use and reuse // an instance of IO. - _yuitest_coverfunc("build/io-base/io-base.js", "io", 877); -_yuitest_coverline("build/io-base/io-base.js", 880); + _yuitest_coverfunc("build/io-base/io-base.js", "io", 880); +_yuitest_coverline("build/io-base/io-base.js", 883); var transaction = Y.io._map['io:0'] || new IO(); - _yuitest_coverline("build/io-base/io-base.js", 881); + _yuitest_coverline("build/io-base/io-base.js", 884); return transaction.send.apply(transaction, [url, config]); }; @@ -1127,23 +1131,23 @@ Hosted as a property on the `io` function (e.g. `Y.io.header`). @param {String} value HTTP header value @static **/ -_yuitest_coverline("build/io-base/io-base.js", 895); +_yuitest_coverline("build/io-base/io-base.js", 898); Y.io.header = function(name, value) { // Calling IO through the static interface will use and reuse // an instance of IO. - _yuitest_coverfunc("build/io-base/io-base.js", "header", 895); -_yuitest_coverline("build/io-base/io-base.js", 898); + _yuitest_coverfunc("build/io-base/io-base.js", "header", 898); +_yuitest_coverline("build/io-base/io-base.js", 901); var transaction = Y.io._map['io:0'] || new IO(); - _yuitest_coverline("build/io-base/io-base.js", 899); + _yuitest_coverline("build/io-base/io-base.js", 902); transaction.setHeader(name, value); }; -_yuitest_coverline("build/io-base/io-base.js", 902); +_yuitest_coverline("build/io-base/io-base.js", 905); Y.IO = IO; // Map of all IO instances created. -_yuitest_coverline("build/io-base/io-base.js", 904); +_yuitest_coverline("build/io-base/io-base.js", 907); Y.io._map = {}; -_yuitest_coverline("build/io-base/io-base.js", 905); +_yuitest_coverline("build/io-base/io-base.js", 908); var XHR = win && win.XMLHttpRequest, XDR = win && win.XDomainRequest, AX = win && win.ActiveXObject, @@ -1153,7 +1157,7 @@ var XHR = win && win.XMLHttpRequest, SUPPORTS_CORS = XHR && 'withCredentials' in (new XMLHttpRequest()); -_yuitest_coverline("build/io-base/io-base.js", 914); +_yuitest_coverline("build/io-base/io-base.js", 917); Y.mix(Y.IO, { /** * The ID of the default IO transport, defaults to `xhr` @@ -1170,18 +1174,18 @@ Y.mix(Y.IO, { * @return {Object} The transport object with a `send` method */ defaultTransport: function(id) { - _yuitest_coverfunc("build/io-base/io-base.js", "defaultTransport", 929); -_yuitest_coverline("build/io-base/io-base.js", 930); + _yuitest_coverfunc("build/io-base/io-base.js", "defaultTransport", 932); +_yuitest_coverline("build/io-base/io-base.js", 933); if (id) { - _yuitest_coverline("build/io-base/io-base.js", 931); + _yuitest_coverline("build/io-base/io-base.js", 934); Y.IO._default = id; } else { - _yuitest_coverline("build/io-base/io-base.js", 933); + _yuitest_coverline("build/io-base/io-base.js", 936); var o = { c: Y.IO.transports[Y.IO._default](), notify: Y.IO._default === 'xhr' ? false : true }; - _yuitest_coverline("build/io-base/io-base.js", 937); + _yuitest_coverline("build/io-base/io-base.js", 940); return o; } }, @@ -1193,18 +1197,18 @@ return o; */ transports: { xhr: function () { - _yuitest_coverfunc("build/io-base/io-base.js", "xhr", 947); -_yuitest_coverline("build/io-base/io-base.js", 948); + _yuitest_coverfunc("build/io-base/io-base.js", "xhr", 950); +_yuitest_coverline("build/io-base/io-base.js", 951); return XHR ? new XMLHttpRequest() : AX ? new ActiveXObject('Microsoft.XMLHTTP') : null; }, xdr: function () { - _yuitest_coverfunc("build/io-base/io-base.js", "xdr", 951); -_yuitest_coverline("build/io-base/io-base.js", 952); + _yuitest_coverfunc("build/io-base/io-base.js", "xdr", 954); +_yuitest_coverline("build/io-base/io-base.js", 955); return XDR ? new XDomainRequest() : null; }, - iframe: function () { _yuitest_coverfunc("build/io-base/io-base.js", "iframe", 954); -_yuitest_coverline("build/io-base/io-base.js", 954); + iframe: function () { _yuitest_coverfunc("build/io-base/io-base.js", "iframe", 957); +_yuitest_coverline("build/io-base/io-base.js", 957); return {}; }, flash: null, nodejs: null @@ -1216,18 +1220,18 @@ return {}; }, * @static */ customTransport: function(id) { - _yuitest_coverfunc("build/io-base/io-base.js", "customTransport", 964); -_yuitest_coverline("build/io-base/io-base.js", 965); + _yuitest_coverfunc("build/io-base/io-base.js", "customTransport", 967); +_yuitest_coverline("build/io-base/io-base.js", 968); var o = { c: Y.IO.transports[id]() }; - _yuitest_coverline("build/io-base/io-base.js", 967); + _yuitest_coverline("build/io-base/io-base.js", 970); o[(id === 'xdr' || id === 'flash') ? 'xdr' : 'notify'] = true; - _yuitest_coverline("build/io-base/io-base.js", 968); + _yuitest_coverline("build/io-base/io-base.js", 971); return o; } }); -_yuitest_coverline("build/io-base/io-base.js", 972); +_yuitest_coverline("build/io-base/io-base.js", 975); Y.mix(Y.IO.prototype, { /** * Fired from the notify method of the transport which in turn fires @@ -1238,21 +1242,21 @@ Y.mix(Y.IO.prototype, { * @param {Object} config The configuration object for this transaction */ notify: function(event, transaction, config) { - _yuitest_coverfunc("build/io-base/io-base.js", "notify", 981); -_yuitest_coverline("build/io-base/io-base.js", 982); + _yuitest_coverfunc("build/io-base/io-base.js", "notify", 984); +_yuitest_coverline("build/io-base/io-base.js", 985); var io = this; - _yuitest_coverline("build/io-base/io-base.js", 984); + _yuitest_coverline("build/io-base/io-base.js", 987); switch (event) { case 'timeout': case 'abort': case 'transport error': - _yuitest_coverline("build/io-base/io-base.js", 988); + _yuitest_coverline("build/io-base/io-base.js", 991); transaction.c = { status: 0, statusText: event }; - _yuitest_coverline("build/io-base/io-base.js", 989); + _yuitest_coverline("build/io-base/io-base.js", 992); event = 'failure'; default: - _yuitest_coverline("build/io-base/io-base.js", 991); + _yuitest_coverline("build/io-base/io-base.js", 994); io[event].apply(io, [transaction, config]); } } diff --git a/build/io-base/io-base-debug.js b/build/io-base/io-base-debug.js index 3077ca85471..5ed2e3dd6d4 100644 --- a/build/io-base/io-base-debug.js +++ b/build/io-base/io-base-debug.js @@ -645,10 +645,15 @@ IO.prototype = { sync = config.sync; data = config.data; - // Serialize an map object into a key-value string using + // Serialize a map object into a key-value string using // querystring-stringify-simple. if ((Y.Lang.isObject(data) && !data.nodeType) && !transaction.upload) { - data = Y.QueryString.stringify(data); + if (Y.QueryString && Y.QueryString.stringify) { + Y.log('Stringifying config.data for request', 'info', 'io'); + config.data = data = Y.QueryString.stringify(data); + } else { + Y.log('Failed to stringify config.data object, likely because `querystring-stringify-simple` is missing.', 'warn', 'io'); + } } if (config.form) { diff --git a/build/io-base/io-base-min.js b/build/io-base/io-base-min.js index 3a45d42d323..0217621940b 100644 --- a/build/io-base/io-base-min.js +++ b/build/io-base/io-base-min.js @@ -1 +1 @@ -YUI.add("io-base",function(e,t){function o(t){var n=this;n._uid="io:"+s++,n._init(t),e.io._map[n._uid]=n}var n=["start","complete","end","success","failure","progress"],r=["status","statusText","responseText","responseXML"],i=e.config.win,s=0;o.prototype={_id:0,_headers:{"X-Requested-With":"XMLHttpRequest"},_timeout:{},_init:function(t){var r=this,i,s;r.cfg=t||{},e.augment(r,e.EventTarget);for(i=0,s=n.length;i=200&&n<300||n===304||n===1223?this.success(e,t):this.failure(e,t)},_rS:function(e,t){var n=this;e.c.readyState===4&&(t.timeout&&n._clearTimeout(e.id),setTimeout(function(){n.complete(e,t),n._result(e,t)},0))},_abort:function(e,t){e&&e.c&&(e.e=t,e.c.abort())},send:function(t,n,i){var s,o,u,a,f,c,h=this,p=t,d={};n=n?e.Object(n):{},s=h._create(n,i),o=n.method?n.method.toUpperCase():"GET",f=n.sync,c=n.data,e.Lang.isObject(c)&&!c.nodeType&&!s.upload&&(c=e.QueryString.stringify(c));if(n.form){if(n.form.upload)return h.upload(s,t,n);c=h._serialize(n.form,c)}if(c)switch(o){case"GET":case"HEAD":case"DELETE":p=h._concat(p,c),c="";break;case"POST":case"PUT":n.headers=e.merge({"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},n.headers)}if(s.xdr)return h.xdr(p,s,n);if(s.notify)return s.c.send(s,t,n);!f&&!s.upload&&(s.c.onreadystatechange=function(){h._rS(s,n)});try{s.c.open(o,p,!f,n.username||null,n.password||null),h._setHeaders(s.c,n.headers||{}),h.start(s,n),n.xdr&&n.xdr.credentials&&l&&(s.c.withCredentials=!0),s.c.send(c);if(f){for(u=0,a=r.length;u=200&&n<300||n===304||n===1223?this.success(e,t):this.failure(e,t)},_rS:function(e,t){var n=this;e.c.readyState===4&&(t.timeout&&n._clearTimeout(e.id),setTimeout(function(){n.complete(e,t),n._result(e,t)},0))},_abort:function(e,t){e&&e.c&&(e.e=t,e.c.abort())},send:function(t,n,i){var s,o,u,a,f,c,h=this,p=t,d={};n=n?e.Object(n):{},s=h._create(n,i),o=n.method?n.method.toUpperCase():"GET",f=n.sync,c=n.data,e.Lang.isObject(c)&&!c.nodeType&&!s.upload&&e.QueryString&&e.QueryString.stringify&&(n.data=c=e.QueryString.stringify(c));if(n.form){if(n.form.upload)return h.upload(s,t,n);c=h._serialize(n.form,c)}if(c)switch(o){case"GET":case"HEAD":case"DELETE":p=h._concat(p,c),c="";break;case"POST":case"PUT":n.headers=e.merge({"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},n.headers)}if(s.xdr)return h.xdr(p,s,n);if(s.notify)return s.c.send(s,t,n);!f&&!s.upload&&(s.c.onreadystatechange=function(){h._rS(s,n)});try{s.c.open(o,p,!f,n.username||null,n.password||null),h._setHeaders(s.c,n.headers||{}),h.start(s,n),n.xdr&&n.xdr.credentials&&l&&(s.c.withCredentials=!0),s.c.send(c);if(f){for(u=0,a=r.length;urequest module."," * This method is return of `require('request')` so you can use it inside NodeJS without"," * the IO abstraction."," * @method request"," * @static"," * @for IO"," */"," if (!Y.IO.request) {"," // Default Request's cookie jar to `false`. This way cookies will not be"," // maintained across requests."," Y.IO.request = require('request').defaults({jar: false});"," }",""," var codes = require('http').STATUS_CODES;",""," /**"," Flatten headers object"," @method flatten"," @protected"," @for IO"," @param {Object} o The headers object"," @return {String} The flattened headers object"," */"," var flatten = function(o) {"," var str = [];"," Object.keys(o).forEach(function(name) {"," str.push(name + ': ' + o[name]);"," });"," return str.join('\\n');"," };","",""," /**"," NodeJS IO transport, uses the NodeJS request"," module under the hood to perform all network IO."," @method transports.nodejs"," @for IO"," @static"," @return {Object} This object contains only a `send` method that accepts a"," `transaction object`, `uri` and the `config object`."," @example",""," Y.io('https://somedomain.com/url', {"," method: 'PUT',"," data: '?foo=bar',"," //Extra request module config options."," request: {"," maxRedirects: 100,"," strictSSL: true,"," multipart: ["," {"," 'content-type': 'application/json',"," body: JSON.stringify({"," foo: 'bar',"," _attachments: {"," 'message.txt': {"," follows: true,"," length: 18,"," 'content_type': 'text/plain'"," }"," }"," })"," },"," {"," body: 'I am an attachment'"," }"," ]"," },"," on: {"," success: function(id, e) {"," }"," }"," });"," */",""," Y.IO.transports.nodejs = function() {"," return {"," send: function (transaction, uri, config) {",""," config.notify('start', transaction, config);"," config.method = config.method || 'GET';"," config.method = config.method.toUpperCase();",""," var rconf = {"," method: config.method,"," uri: uri"," };",""," if (config.data) {"," if (Y.Lang.isObject(config.data)) {"," if (Y.QueryString && Y.QueryString.stringify) {"," rconf.body = Y.QueryString.stringify(config.data);"," } else {"," }"," } else if (Y.Lang.isString(config.data)) {"," rconf.body = config.data;"," }"," if (rconf.method === 'GET') {"," rconf.uri += (rconf.uri.indexOf('?') > -1 ? '&' : '?') + rconf.body;"," rconf.body = '';"," }"," }"," if (config.headers) {"," rconf.headers = config.headers;"," }"," if (config.timeout) {"," rconf.timeout = config.timeout;"," }"," if (config.request) {"," Y.mix(rconf, config.request);"," }"," Y.IO.request(rconf, function(err, data) {",""," if (err) {"," transaction.c = err;"," config.notify(((err.code === 'ETIMEDOUT') ? 'timeout' : 'failure'), transaction, config);"," return;"," }"," if (data) {"," transaction.c = {"," status: data.statusCode,"," statusCode: data.statusCode,"," statusText: codes[data.statusCode],"," headers: data.headers,"," responseText: data.body,"," responseXML: null,"," getResponseHeader: function(name) {"," return this.headers[name];"," },"," getAllResponseHeaders: function() {"," return flatten(this.headers);"," }"," };"," }",""," config.notify('complete', transaction, config);"," config.notify(((data && (data.statusCode >= 200 && data.statusCode <= 299)) ? 'success' : 'failure'), transaction, config);"," });",""," var ret = {"," io: transaction"," };"," return ret;"," }"," };"," };",""," Y.IO.defaultTransport('nodejs');","","","","}, '@VERSION@', {\"requires\": [\"io-base\"]});"]; -_yuitest_coverage["build/io-nodejs/io-nodejs.js"].lines = {"1":0,"17":0,"20":0,"23":0,"33":0,"34":0,"35":0,"36":0,"38":0,"85":0,"86":0,"89":0,"90":0,"91":0,"93":0,"98":0,"99":0,"100":0,"101":0,"104":0,"105":0,"107":0,"108":0,"109":0,"112":0,"113":0,"115":0,"116":0,"118":0,"119":0,"121":0,"123":0,"124":0,"125":0,"126":0,"128":0,"129":0,"137":0,"140":0,"145":0,"146":0,"149":0,"152":0,"157":0}; -_yuitest_coverage["build/io-nodejs/io-nodejs.js"].functions = {"(anonymous 2):35":0,"flatten:33":0,"getResponseHeader:136":0,"getAllResponseHeaders:139":0,"(anonymous 3):121":0,"send:87":0,"nodejs:85":0,"(anonymous 1):1":0}; -_yuitest_coverage["build/io-nodejs/io-nodejs.js"].coveredLines = 44; +_yuitest_coverage["build/io-nodejs/io-nodejs.js"].code=["YUI.add('io-nodejs', function (Y, NAME) {","","/*global Y: false, Buffer: false, clearInterval: false, clearTimeout: false, console: false, exports: false, global: false, module: false, process: false, querystring: false, require: false, setInterval: false, setTimeout: false, __filename: false, __dirname: false */"," /**"," * Node.js override for IO, methods are mixed into `Y.IO`"," * @module io-nodejs"," * @main io-nodejs"," */"," /**"," * Passthru to the NodeJS request module."," * This method is return of `require('request')` so you can use it inside NodeJS without"," * the IO abstraction."," * @method request"," * @static"," * @for IO"," */"," if (!Y.IO.request) {"," // Default Request's cookie jar to `false`. This way cookies will not be"," // maintained across requests."," Y.IO.request = require('request').defaults({jar: false});"," }",""," var codes = require('http').STATUS_CODES;",""," /**"," Flatten headers object"," @method flatten"," @protected"," @for IO"," @param {Object} o The headers object"," @return {String} The flattened headers object"," */"," var flatten = function(o) {"," var str = [];"," Object.keys(o).forEach(function(name) {"," str.push(name + ': ' + o[name]);"," });"," return str.join('\\n');"," };","",""," /**"," NodeJS IO transport, uses the NodeJS request"," module under the hood to perform all network IO."," @method transports.nodejs"," @for IO"," @static"," @return {Object} This object contains only a `send` method that accepts a"," `transaction object`, `uri` and the `config object`."," @example",""," Y.io('https://somedomain.com/url', {"," method: 'PUT',"," data: '?foo=bar',"," //Extra request module config options."," request: {"," maxRedirects: 100,"," strictSSL: true,"," multipart: ["," {"," 'content-type': 'application/json',"," body: JSON.stringify({"," foo: 'bar',"," _attachments: {"," 'message.txt': {"," follows: true,"," length: 18,"," 'content_type': 'text/plain'"," }"," }"," })"," },"," {"," body: 'I am an attachment'"," }"," ]"," },"," on: {"," success: function(id, e) {"," }"," }"," });"," */",""," Y.IO.transports.nodejs = function() {"," return {"," send: function (transaction, uri, config) {",""," config.notify('start', transaction, config);"," config.method = config.method || 'GET';"," config.method = config.method.toUpperCase();",""," var rconf = {"," method: config.method,"," uri: uri"," };",""," if (config.data) {"," if (Y.Lang.isString(config.data)) {"," rconf.body = config.data;"," }"," if (rconf.body && rconf.method === 'GET') {"," rconf.uri += (rconf.uri.indexOf('?') > -1 ? '&' : '?') + rconf.body;"," rconf.body = '';"," }"," }"," if (config.headers) {"," rconf.headers = config.headers;"," }"," if (config.timeout) {"," rconf.timeout = config.timeout;"," }"," if (config.request) {"," Y.mix(rconf, config.request);"," }"," Y.IO.request(rconf, function(err, data) {",""," if (err) {"," transaction.c = err;"," config.notify(((err.code === 'ETIMEDOUT') ? 'timeout' : 'failure'), transaction, config);"," return;"," }"," if (data) {"," transaction.c = {"," status: data.statusCode,"," statusCode: data.statusCode,"," statusText: codes[data.statusCode],"," headers: data.headers,"," responseText: data.body,"," responseXML: null,"," getResponseHeader: function(name) {"," return this.headers[name];"," },"," getAllResponseHeaders: function() {"," return flatten(this.headers);"," }"," };"," }",""," config.notify('complete', transaction, config);"," config.notify(((data && (data.statusCode >= 200 && data.statusCode <= 299)) ? 'success' : 'failure'), transaction, config);"," });",""," var ret = {"," io: transaction"," };"," return ret;"," }"," };"," };",""," Y.IO.defaultTransport('nodejs');","","","","}, '@VERSION@', {\"requires\": [\"io-base\"]});"]; +_yuitest_coverage["build/io-nodejs/io-nodejs.js"].lines = {"1":0,"17":0,"20":0,"23":0,"33":0,"34":0,"35":0,"36":0,"38":0,"85":0,"86":0,"89":0,"90":0,"91":0,"93":0,"98":0,"99":0,"100":0,"102":0,"103":0,"104":0,"107":0,"108":0,"110":0,"111":0,"113":0,"114":0,"116":0,"118":0,"119":0,"120":0,"121":0,"123":0,"124":0,"132":0,"135":0,"140":0,"141":0,"144":0,"147":0,"152":0}; +_yuitest_coverage["build/io-nodejs/io-nodejs.js"].functions = {"(anonymous 2):35":0,"flatten:33":0,"getResponseHeader:131":0,"getAllResponseHeaders:134":0,"(anonymous 3):116":0,"send:87":0,"nodejs:85":0,"(anonymous 1):1":0}; +_yuitest_coverage["build/io-nodejs/io-nodejs.js"].coveredLines = 41; _yuitest_coverage["build/io-nodejs/io-nodejs.js"].coveredFunctions = 8; _yuitest_coverline("build/io-nodejs/io-nodejs.js", 1); YUI.add('io-nodejs', function (Y, NAME) { @@ -151,57 +151,49 @@ var rconf = { _yuitest_coverline("build/io-nodejs/io-nodejs.js", 98); if (config.data) { _yuitest_coverline("build/io-nodejs/io-nodejs.js", 99); -if (Y.Lang.isObject(config.data)) { - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 100); -if (Y.QueryString && Y.QueryString.stringify) { - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 101); -rconf.body = Y.QueryString.stringify(config.data); - } else { - } - } else {_yuitest_coverline("build/io-nodejs/io-nodejs.js", 104); if (Y.Lang.isString(config.data)) { - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 105); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 100); rconf.body = config.data; - }} - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 107); -if (rconf.method === 'GET') { - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 108); + } + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 102); +if (rconf.body && rconf.method === 'GET') { + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 103); rconf.uri += (rconf.uri.indexOf('?') > -1 ? '&' : '?') + rconf.body; - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 109); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 104); rconf.body = ''; } } - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 112); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 107); if (config.headers) { - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 113); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 108); rconf.headers = config.headers; } - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 115); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 110); if (config.timeout) { - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 116); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 111); rconf.timeout = config.timeout; } - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 118); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 113); if (config.request) { - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 119); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 114); Y.mix(rconf, config.request); } - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 121); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 116); Y.IO.request(rconf, function(err, data) { - _yuitest_coverfunc("build/io-nodejs/io-nodejs.js", "(anonymous 3)", 121); -_yuitest_coverline("build/io-nodejs/io-nodejs.js", 123); + _yuitest_coverfunc("build/io-nodejs/io-nodejs.js", "(anonymous 3)", 116); +_yuitest_coverline("build/io-nodejs/io-nodejs.js", 118); if (err) { - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 124); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 119); transaction.c = err; - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 125); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 120); config.notify(((err.code === 'ETIMEDOUT') ? 'timeout' : 'failure'), transaction, config); - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 126); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 121); return; } - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 128); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 123); if (data) { - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 129); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 124); transaction.c = { status: data.statusCode, statusCode: data.statusCode, @@ -210,35 +202,35 @@ transaction.c = { responseText: data.body, responseXML: null, getResponseHeader: function(name) { - _yuitest_coverfunc("build/io-nodejs/io-nodejs.js", "getResponseHeader", 136); -_yuitest_coverline("build/io-nodejs/io-nodejs.js", 137); + _yuitest_coverfunc("build/io-nodejs/io-nodejs.js", "getResponseHeader", 131); +_yuitest_coverline("build/io-nodejs/io-nodejs.js", 132); return this.headers[name]; }, getAllResponseHeaders: function() { - _yuitest_coverfunc("build/io-nodejs/io-nodejs.js", "getAllResponseHeaders", 139); -_yuitest_coverline("build/io-nodejs/io-nodejs.js", 140); + _yuitest_coverfunc("build/io-nodejs/io-nodejs.js", "getAllResponseHeaders", 134); +_yuitest_coverline("build/io-nodejs/io-nodejs.js", 135); return flatten(this.headers); } }; } - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 145); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 140); config.notify('complete', transaction, config); - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 146); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 141); config.notify(((data && (data.statusCode >= 200 && data.statusCode <= 299)) ? 'success' : 'failure'), transaction, config); }); - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 149); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 144); var ret = { io: transaction }; - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 152); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 147); return ret; } }; }; - _yuitest_coverline("build/io-nodejs/io-nodejs.js", 157); + _yuitest_coverline("build/io-nodejs/io-nodejs.js", 152); Y.IO.defaultTransport('nodejs'); diff --git a/build/io-nodejs/io-nodejs-debug.js b/build/io-nodejs/io-nodejs-debug.js index 7c824fbbc40..b640bde2a1a 100644 --- a/build/io-nodejs/io-nodejs-debug.js +++ b/build/io-nodejs/io-nodejs-debug.js @@ -99,17 +99,10 @@ YUI.add('io-nodejs', function (Y, NAME) { }; if (config.data) { - if (Y.Lang.isObject(config.data)) { - if (Y.QueryString && Y.QueryString.stringify) { - Y.log('Stringifying config.data for request', 'info', 'io'); - rconf.body = Y.QueryString.stringify(config.data); - } else { - Y.log('Failed to stringify config.data object, likely because `querystring-stringify-simple` is missing.', 'warn', 'io'); - } - } else if (Y.Lang.isString(config.data)) { + if (Y.Lang.isString(config.data)) { rconf.body = config.data; } - if (rconf.method === 'GET') { + if (rconf.body && rconf.method === 'GET') { rconf.uri += (rconf.uri.indexOf('?') > -1 ? '&' : '?') + rconf.body; rconf.body = ''; } diff --git a/build/io-nodejs/io-nodejs-min.js b/build/io-nodejs/io-nodejs-min.js index 96722598afb..c27002aa04d 100644 --- a/build/io-nodejs/io-nodejs-min.js +++ b/build/io-nodejs/io-nodejs-min.js @@ -1 +1 @@ -YUI.add("io-nodejs",function(e,t){e.IO.request||(e.IO.request=require("request").defaults({jar:!1}));var n=require("http").STATUS_CODES,r=function(e){var t=[];return Object.keys(e).forEach(function(n){t.push(n+": "+e[n])}),t.join("\n")};e.IO.transports.nodejs=function(){return{send:function(t,i,s){s.notify("start",t,s),s.method=s.method||"GET",s.method=s.method.toUpperCase();var o={method:s.method,uri:i};s.data&&(e.Lang.isObject(s.data)?e.QueryString&&e.QueryString.stringify&&(o.body=e.QueryString.stringify(s.data)):e.Lang.isString(s.data)&&(o.body=s.data),o.method==="GET"&&(o.uri+=(o.uri.indexOf("?")>-1?"&":"?")+o.body,o.body="")),s.headers&&(o.headers=s.headers),s.timeout&&(o.timeout=s.timeout),s.request&&e.mix(o,s.request),e.IO.request(o,function(e,i){if(e){t.c=e,s.notify(e.code==="ETIMEDOUT"?"timeout":"failure",t,s);return}i&&(t.c={status:i.statusCode,statusCode:i.statusCode,statusText:n[i.statusCode],headers:i.headers,responseText:i.body,responseXML:null,getResponseHeader:function(e){return this.headers[e]},getAllResponseHeaders:function(){return r(this.headers)}}),s.notify("complete",t,s),s.notify(i&&i.statusCode>=200&&i.statusCode<=299?"success":"failure",t,s)});var u={io:t};return u}}},e.IO.defaultTransport("nodejs")},"@VERSION@",{requires:["io-base"]}); +YUI.add("io-nodejs",function(e,t){e.IO.request||(e.IO.request=require("request").defaults({jar:!1}));var n=require("http").STATUS_CODES,r=function(e){var t=[];return Object.keys(e).forEach(function(n){t.push(n+": "+e[n])}),t.join("\n")};e.IO.transports.nodejs=function(){return{send:function(t,i,s){s.notify("start",t,s),s.method=s.method||"GET",s.method=s.method.toUpperCase();var o={method:s.method,uri:i};s.data&&(e.Lang.isString(s.data)&&(o.body=s.data),o.body&&o.method==="GET"&&(o.uri+=(o.uri.indexOf("?")>-1?"&":"?")+o.body,o.body="")),s.headers&&(o.headers=s.headers),s.timeout&&(o.timeout=s.timeout),s.request&&e.mix(o,s.request),e.IO.request(o,function(e,i){if(e){t.c=e,s.notify(e.code==="ETIMEDOUT"?"timeout":"failure",t,s);return}i&&(t.c={status:i.statusCode,statusCode:i.statusCode,statusText:n[i.statusCode],headers:i.headers,responseText:i.body,responseXML:null,getResponseHeader:function(e){return this.headers[e]},getAllResponseHeaders:function(){return r(this.headers)}}),s.notify("complete",t,s),s.notify(i&&i.statusCode>=200&&i.statusCode<=299?"success":"failure",t,s)});var u={io:t};return u}}},e.IO.defaultTransport("nodejs")},"@VERSION@",{requires:["io-base"]}); diff --git a/build/io-nodejs/io-nodejs.js b/build/io-nodejs/io-nodejs.js index e88c36ebfd0..cf5958678b8 100644 --- a/build/io-nodejs/io-nodejs.js +++ b/build/io-nodejs/io-nodejs.js @@ -96,15 +96,10 @@ YUI.add('io-nodejs', function (Y, NAME) { }; if (config.data) { - if (Y.Lang.isObject(config.data)) { - if (Y.QueryString && Y.QueryString.stringify) { - rconf.body = Y.QueryString.stringify(config.data); - } else { - } - } else if (Y.Lang.isString(config.data)) { + if (Y.Lang.isString(config.data)) { rconf.body = config.data; } - if (rconf.method === 'GET') { + if (rconf.body && rconf.method === 'GET') { rconf.uri += (rconf.uri.indexOf('?') > -1 ? '&' : '?') + rconf.body; rconf.body = ''; } diff --git a/src/io/js/io-base.js b/src/io/js/io-base.js index 0a4d348947d..5020b894a1a 100644 --- a/src/io/js/io-base.js +++ b/src/io/js/io-base.js @@ -643,10 +643,15 @@ IO.prototype = { sync = config.sync; data = config.data; - // Serialize an map object into a key-value string using + // Serialize a map object into a key-value string using // querystring-stringify-simple. if ((Y.Lang.isObject(data) && !data.nodeType) && !transaction.upload) { - data = Y.QueryString.stringify(data); + if (Y.QueryString && Y.QueryString.stringify) { + Y.log('Stringifying config.data for request', 'info', 'io'); + config.data = data = Y.QueryString.stringify(data); + } else { + Y.log('Failed to stringify config.data object, likely because `querystring-stringify-simple` is missing.', 'warn', 'io'); + } } if (config.form) { diff --git a/src/io/js/io-nodejs.js b/src/io/js/io-nodejs.js index 904a848a01c..eb25fedb19b 100644 --- a/src/io/js/io-nodejs.js +++ b/src/io/js/io-nodejs.js @@ -97,17 +97,10 @@ }; if (config.data) { - if (Y.Lang.isObject(config.data)) { - if (Y.QueryString && Y.QueryString.stringify) { - Y.log('Stringifying config.data for request', 'info', 'io'); - rconf.body = Y.QueryString.stringify(config.data); - } else { - Y.log('Failed to stringify config.data object, likely because `querystring-stringify-simple` is missing.', 'warn', 'io'); - } - } else if (Y.Lang.isString(config.data)) { + if (Y.Lang.isString(config.data)) { rconf.body = config.data; } - if (rconf.method === 'GET') { + if (rconf.body && rconf.method === 'GET') { rconf.uri += (rconf.uri.indexOf('?') > -1 ? '&' : '?') + rconf.body; rconf.body = ''; }