mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2024-11-25 14:17:45 +00:00
Make mockjax log work in IE8
This commit is contained in:
parent
93c147e4c0
commit
be517ccb33
@ -455,6 +455,8 @@
|
||||
mockHandler.timeout = requestSettings.timeout;
|
||||
mockHandler.global = requestSettings.global;
|
||||
|
||||
copyUrlParameters(mockHandler, origSettings);
|
||||
|
||||
(function(mockHandler, requestSettings, origSettings, origHandler) {
|
||||
mockRequest = _ajax.call($, $.extend(true, {}, origSettings, {
|
||||
// Mock the XHR object
|
||||
@ -469,6 +471,40 @@
|
||||
return _ajax.apply($, [origSettings]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies URL parameter values if they were captured by a regular expression
|
||||
* @param {Object} mockHandler
|
||||
* @param {Object} origSettings
|
||||
*/
|
||||
function copyUrlParameters(mockHandler, origSettings) {
|
||||
//parameters aren't captured if the URL isn't a RegExp
|
||||
if (!mockHandler.url instanceof RegExp) {
|
||||
return;
|
||||
}
|
||||
//if no URL params were defined on the handler, don't attempt a capture
|
||||
if (!mockHandler.hasOwnProperty('urlParams')) {
|
||||
return;
|
||||
}
|
||||
var captures = mockHandler.url.exec(origSettings.url);
|
||||
//the whole RegExp match is always the first value in the capture results
|
||||
if (captures.length === 1) {
|
||||
return;
|
||||
}
|
||||
captures.shift();
|
||||
//use handler params as keys and capture resuts as values
|
||||
var i = 0,
|
||||
capturesLength = captures.length,
|
||||
paramsLength = mockHandler.urlParams.length,
|
||||
//in case the number of params specified is less than actual captures
|
||||
maxIterations = Math.min(capturesLength, paramsLength),
|
||||
paramValues = {};
|
||||
for (i; i < maxIterations; i++) {
|
||||
var key = mockHandler.urlParams[i];
|
||||
paramValues[key] = captures[i];
|
||||
}
|
||||
origSettings.urlParams = paramValues;
|
||||
}
|
||||
|
||||
|
||||
// Public
|
||||
|
||||
@ -480,8 +516,13 @@
|
||||
//url: null,
|
||||
//type: 'GET',
|
||||
log: function( msg ) {
|
||||
if ( window[ 'console' ] && window.console.log ) {
|
||||
window.console.log.apply( console, arguments );
|
||||
if (window['console'] && window.console.log) {
|
||||
if (!Function.prototype.bind) {
|
||||
console.log(Array.prototype.slice.call(arguments).join(', '));
|
||||
return;
|
||||
}
|
||||
var log = Function.prototype.bind.call(console.log, console);
|
||||
log.apply(console, arguments);
|
||||
}
|
||||
},
|
||||
status: 200,
|
||||
|
Loading…
Reference in New Issue
Block a user