Commit 534e98d5 authored by Romain Courteaud's avatar Romain Courteaud

Upgrade jquery and qunit

parent f8019bd0
This source diff could not be displayed because it is too large. You can view the blob instead.
/** /**
* QUnit v1.11.0 - A JavaScript Unit Testing Framework * QUnit v1.12.0 - A JavaScript Unit Testing Framework
* *
* http://qunitjs.com * http://qunitjs.com
* *
......
/** /**
* QUnit v1.11.0 - A JavaScript Unit Testing Framework * QUnit v1.12.0 - A JavaScript Unit Testing Framework
* *
* http://qunitjs.com * http://qunitjs.com
* *
* Copyright 2012 jQuery Foundation and other contributors * Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license. * Released under the MIT license.
* http://jquery.org/license * https://jquery.org/license/
*/ */
(function( window ) { (function( window ) {
...@@ -20,6 +20,7 @@ var QUnit, ...@@ -20,6 +20,7 @@ var QUnit,
hasOwn = Object.prototype.hasOwnProperty, hasOwn = Object.prototype.hasOwnProperty,
// Keep a local reference to Date (GH-283) // Keep a local reference to Date (GH-283)
Date = window.Date, Date = window.Date,
setTimeout = window.setTimeout,
defined = { defined = {
setTimeout: typeof window.setTimeout !== "undefined", setTimeout: typeof window.setTimeout !== "undefined",
sessionStorage: (function() { sessionStorage: (function() {
...@@ -115,8 +116,16 @@ Test.prototype = { ...@@ -115,8 +116,16 @@ Test.prototype = {
} }
}, },
setup: function() { setup: function() {
if ( this.module !== config.previousModule ) { if (
if ( config.previousModule ) { // Emit moduleStart when we're switching from one module to another
this.module !== config.previousModule ||
// They could be equal (both undefined) but if the previousModule property doesn't
// yet exist it means this is the first test in a suite that isn't wrapped in a
// module, in which case we'll just emit a moduleStart event for 'undefined'.
// Without this, reporters can get testStart before moduleStart which is a problem.
!hasOwn.call( config, "previousModule" )
) {
if ( hasOwn.call( config, "previousModule" ) ) {
runLoggingCallbacks( "moduleDone", QUnit, { runLoggingCallbacks( "moduleDone", QUnit, {
name: config.previousModule, name: config.previousModule,
failed: config.moduleStats.bad, failed: config.moduleStats.bad,
...@@ -129,10 +138,6 @@ Test.prototype = { ...@@ -129,10 +138,6 @@ Test.prototype = {
runLoggingCallbacks( "moduleStart", QUnit, { runLoggingCallbacks( "moduleStart", QUnit, {
name: this.module name: this.module
}); });
} else if ( config.autorun ) {
runLoggingCallbacks( "moduleStart", QUnit, {
name: this.module
});
} }
config.current = this; config.current = this;
...@@ -148,19 +153,27 @@ Test.prototype = { ...@@ -148,19 +153,27 @@ Test.prototype = {
module: this.module module: this.module
}); });
// allow utility functions to access the current test environment /*jshint camelcase:false */
// TODO why??
/**
* Expose the current test environment.
*
* @deprecated since 1.12.0: Use QUnit.config.current.testEnvironment instead.
*/
QUnit.current_testEnvironment = this.testEnvironment; QUnit.current_testEnvironment = this.testEnvironment;
/*jshint camelcase:true */
if ( !config.pollution ) { if ( !config.pollution ) {
saveGlobal(); saveGlobal();
} }
if ( config.notrycatch ) { if ( config.notrycatch ) {
this.testEnvironment.setup.call( this.testEnvironment ); this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert );
return; return;
} }
try { try {
this.testEnvironment.setup.call( this.testEnvironment ); this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert );
} catch( e ) { } catch( e ) {
QUnit.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); QUnit.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) );
} }
...@@ -208,11 +221,11 @@ Test.prototype = { ...@@ -208,11 +221,11 @@ Test.prototype = {
if ( typeof this.callbackRuntime === "undefined" ) { if ( typeof this.callbackRuntime === "undefined" ) {
this.callbackRuntime = +new Date() - this.callbackStarted; this.callbackRuntime = +new Date() - this.callbackStarted;
} }
this.testEnvironment.teardown.call( this.testEnvironment ); this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert );
return; return;
} else { } else {
try { try {
this.testEnvironment.teardown.call( this.testEnvironment ); this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert );
} catch( e ) { } catch( e ) {
QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) );
} }
...@@ -419,7 +432,7 @@ QUnit = { ...@@ -419,7 +432,7 @@ QUnit = {
test.queue(); test.queue();
}, },
// Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through. // Specify the number of expected assertions to guarantee that failed test (no assertions are run at all) don't slip through.
expect: function( asserts ) { expect: function( asserts ) {
if (arguments.length === 1) { if (arguments.length === 1) {
config.current.expected = asserts; config.current.expected = asserts;
...@@ -454,7 +467,7 @@ QUnit = { ...@@ -454,7 +467,7 @@ QUnit = {
} }
// A slight delay, to avoid any current callbacks // A slight delay, to avoid any current callbacks
if ( defined.setTimeout ) { if ( defined.setTimeout ) {
window.setTimeout(function() { setTimeout(function() {
if ( config.semaphore > 0 ) { if ( config.semaphore > 0 ) {
return; return;
} }
...@@ -477,7 +490,7 @@ QUnit = { ...@@ -477,7 +490,7 @@ QUnit = {
if ( config.testTimeout && defined.setTimeout ) { if ( config.testTimeout && defined.setTimeout ) {
clearTimeout( config.timeout ); clearTimeout( config.timeout );
config.timeout = window.setTimeout(function() { config.timeout = setTimeout(function() {
QUnit.ok( false, "Test timed out" ); QUnit.ok( false, "Test timed out" );
config.semaphore = 1; config.semaphore = 1;
QUnit.start(); QUnit.start();
...@@ -487,7 +500,7 @@ QUnit = { ...@@ -487,7 +500,7 @@ QUnit = {
}; };
// `assert` initialized at top of scope // `assert` initialized at top of scope
// Asssert helpers // Assert helpers
// All of these must either call QUnit.push() or manually do: // All of these must either call QUnit.push() or manually do:
// - runLoggingCallbacks( "log", .. ); // - runLoggingCallbacks( "log", .. );
// - config.current.assertions.push({ .. }); // - config.current.assertions.push({ .. });
...@@ -505,6 +518,7 @@ assert = { ...@@ -505,6 +518,7 @@ assert = {
throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) ); throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) );
} }
result = !!result; result = !!result;
msg = msg || (result ? "okay" : "failed" );
var source, var source,
details = { details = {
...@@ -514,8 +528,7 @@ assert = { ...@@ -514,8 +528,7 @@ assert = {
message: msg message: msg
}; };
msg = escapeText( msg || (result ? "okay" : "failed" ) ); msg = "<span class='test-message'>" + escapeText( msg ) + "</span>";
msg = "<span class='test-message'>" + msg + "</span>";
if ( !result ) { if ( !result ) {
source = sourceFromStacktrace( 2 ); source = sourceFromStacktrace( 2 );
...@@ -642,13 +655,13 @@ assert = { ...@@ -642,13 +655,13 @@ assert = {
QUnit.push( ok, actual, expectedOutput, message ); QUnit.push( ok, actual, expectedOutput, message );
} else { } else {
QUnit.pushFailure( message, null, 'No exception was thrown.' ); QUnit.pushFailure( message, null, "No exception was thrown." );
} }
} }
}; };
/** /**
* @deprecate since 1.8.0 * @deprecated since 1.8.0
* Kept assertion helpers in root for backwards compatibility. * Kept assertion helpers in root for backwards compatibility.
*/ */
extend( QUnit, assert ); extend( QUnit, assert );
...@@ -737,7 +750,7 @@ config = { ...@@ -737,7 +750,7 @@ config = {
// Export global variables, unless an 'exports' object exists, // Export global variables, unless an 'exports' object exists,
// in that case we assume we're in CommonJS (dealt with on the bottom of the script) // in that case we assume we're in CommonJS (dealt with on the bottom of the script)
if ( typeof exports === "undefined" ) { if ( typeof exports === "undefined" ) {
extend( window, QUnit ); extend( window, QUnit.constructor.prototype );
// Expose QUnit object // Expose QUnit object
window.QUnit = QUnit; window.QUnit = QUnit;
...@@ -836,6 +849,11 @@ extend( QUnit, { ...@@ -836,6 +849,11 @@ extend( QUnit, {
}, },
// Resets the test setup. Useful for tests that modify the DOM. // Resets the test setup. Useful for tests that modify the DOM.
/*
DEPRECATED: Use multiple tests instead of resetting inside a test.
Use testStart or testDone for custom cleanup.
This method will throw an error in 2.0, and will be removed in 2.1
*/
reset: function() { reset: function() {
var fixture = id( "qunit-fixture" ); var fixture = id( "qunit-fixture" );
if ( fixture ) { if ( fixture ) {
...@@ -985,11 +1003,10 @@ extend( QUnit, { ...@@ -985,11 +1003,10 @@ extend( QUnit, {
querystring = "?"; querystring = "?";
for ( key in params ) { for ( key in params ) {
if ( !hasOwn.call( params, key ) ) { if ( hasOwn.call( params, key ) ) {
continue; querystring += encodeURIComponent( key ) + "=" +
encodeURIComponent( params[ key ] ) + "&";
} }
querystring += encodeURIComponent( key ) + "=" +
encodeURIComponent( params[ key ] ) + "&";
} }
return window.location.protocol + "//" + window.location.host + return window.location.protocol + "//" + window.location.host +
window.location.pathname + querystring.slice( 0, -1 ); window.location.pathname + querystring.slice( 0, -1 );
...@@ -997,7 +1014,10 @@ extend( QUnit, { ...@@ -997,7 +1014,10 @@ extend( QUnit, {
extend: extend, extend: extend,
id: id, id: id,
addEvent: addEvent addEvent: addEvent,
addClass: addClass,
hasClass: hasClass,
removeClass: removeClass
// load, equiv, jsDump, diff: Attached later // load, equiv, jsDump, diff: Attached later
}); });
...@@ -1044,6 +1064,7 @@ QUnit.load = function() { ...@@ -1044,6 +1064,7 @@ QUnit.load = function() {
var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, var banner, filter, i, label, len, main, ol, toolbar, userAgent, val,
urlConfigCheckboxesContainer, urlConfigCheckboxes, moduleFilter, urlConfigCheckboxesContainer, urlConfigCheckboxes, moduleFilter,
numModules = 0, numModules = 0,
moduleNames = [],
moduleFilterHtml = "", moduleFilterHtml = "",
urlConfigHtml = "", urlConfigHtml = "",
oldconfig = extend( {}, config ); oldconfig = extend( {}, config );
...@@ -1072,18 +1093,24 @@ QUnit.load = function() { ...@@ -1072,18 +1093,24 @@ QUnit.load = function() {
"'><label for='qunit-urlconfig-" + escapeText( val.id ) + "'><label for='qunit-urlconfig-" + escapeText( val.id ) +
"' title='" + escapeText( val.tooltip ) + "'>" + val.label + "</label>"; "' title='" + escapeText( val.tooltip ) + "'>" + val.label + "</label>";
} }
for ( i in config.modules ) {
if ( config.modules.hasOwnProperty( i ) ) {
moduleNames.push(i);
}
}
numModules = moduleNames.length;
moduleNames.sort( function( a, b ) {
return a.localeCompare( b );
});
moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " + moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " +
( config.module === undefined ? "selected='selected'" : "" ) + ( config.module === undefined ? "selected='selected'" : "" ) +
">< All Modules ></option>"; ">< All Modules ></option>";
for ( i in config.modules ) {
if ( config.modules.hasOwnProperty( i ) ) { for ( i = 0; i < numModules; i++) {
numModules += 1; moduleFilterHtml += "<option value='" + escapeText( encodeURIComponent(moduleNames[i]) ) + "' " +
moduleFilterHtml += "<option value='" + escapeText( encodeURIComponent(i) ) + "' " + ( config.module === moduleNames[i] ? "selected='selected'" : "" ) +
( config.module === i ? "selected='selected'" : "" ) + ">" + escapeText(moduleNames[i]) + "</option>";
">" + escapeText(i) + "</option>";
}
} }
moduleFilterHtml += "</select>"; moduleFilterHtml += "</select>";
...@@ -1137,7 +1164,7 @@ QUnit.load = function() { ...@@ -1137,7 +1164,7 @@ QUnit.load = function() {
// `label` initialized at top of scope // `label` initialized at top of scope
label = document.createElement( "label" ); label = document.createElement( "label" );
label.setAttribute( "for", "qunit-filter-pass" ); label.setAttribute( "for", "qunit-filter-pass" );
label.setAttribute( "title", "Only show tests and assertons that fail. Stored in sessionStorage." ); label.setAttribute( "title", "Only show tests and assertions that fail. Stored in sessionStorage." );
label.innerHTML = "Hide passed tests"; label.innerHTML = "Hide passed tests";
toolbar.appendChild( label ); toolbar.appendChild( label );
...@@ -1157,14 +1184,19 @@ QUnit.load = function() { ...@@ -1157,14 +1184,19 @@ QUnit.load = function() {
toolbar.appendChild( urlConfigCheckboxesContainer ); toolbar.appendChild( urlConfigCheckboxesContainer );
if (numModules > 1) { if (numModules > 1) {
moduleFilter = document.createElement( 'span' ); moduleFilter = document.createElement( "span" );
moduleFilter.setAttribute( 'id', 'qunit-modulefilter-container' ); moduleFilter.setAttribute( "id", "qunit-modulefilter-container" );
moduleFilter.innerHTML = moduleFilterHtml; moduleFilter.innerHTML = moduleFilterHtml;
addEvent( moduleFilter.lastChild, "change", function() { addEvent( moduleFilter.lastChild, "change", function() {
var selectBox = moduleFilter.getElementsByTagName("select")[0], var selectBox = moduleFilter.getElementsByTagName("select")[0],
selectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value); selectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value);
window.location = QUnit.url( { module: ( selectedModule === "" ) ? undefined : selectedModule } ); window.location = QUnit.url({
module: ( selectedModule === "" ) ? undefined : selectedModule,
// Remove any existing filters
filter: undefined,
testNumber: undefined
});
}); });
toolbar.appendChild(moduleFilter); toolbar.appendChild(moduleFilter);
} }
...@@ -1188,7 +1220,7 @@ addEvent( window, "load", QUnit.load ); ...@@ -1188,7 +1220,7 @@ addEvent( window, "load", QUnit.load );
onErrorFnPrev = window.onerror; onErrorFnPrev = window.onerror;
// Cover uncaught exceptions // Cover uncaught exceptions
// Returning true will surpress the default browser handler, // Returning true will suppress the default browser handler,
// returning false will let it run. // returning false will let it run.
window.onerror = function ( error, filePath, linerNr ) { window.onerror = function ( error, filePath, linerNr ) {
var ret = false; var ret = false;
...@@ -1197,7 +1229,7 @@ window.onerror = function ( error, filePath, linerNr ) { ...@@ -1197,7 +1229,7 @@ window.onerror = function ( error, filePath, linerNr ) {
} }
// Treat return value as window.onerror itself does, // Treat return value as window.onerror itself does,
// Only do our handling if not surpressed. // Only do our handling if not suppressed.
if ( ret !== true ) { if ( ret !== true ) {
if ( QUnit.config.current ) { if ( QUnit.config.current ) {
if ( QUnit.config.current.ignoreGlobalErrors ) { if ( QUnit.config.current.ignoreGlobalErrors ) {
...@@ -1227,6 +1259,7 @@ function done() { ...@@ -1227,6 +1259,7 @@ function done() {
total: config.moduleStats.all total: config.moduleStats.all
}); });
} }
delete config.previousModule;
var i, key, var i, key,
banner = id( "qunit-banner" ), banner = id( "qunit-banner" ),
...@@ -1386,16 +1419,16 @@ function escapeText( s ) { ...@@ -1386,16 +1419,16 @@ function escapeText( s ) {
// Both single quotes and double quotes (for attributes) // Both single quotes and double quotes (for attributes)
return s.replace( /['"<>&]/g, function( s ) { return s.replace( /['"<>&]/g, function( s ) {
switch( s ) { switch( s ) {
case '\'': case "'":
return '&#039;'; return "&#039;";
case '"': case "\"":
return '&quot;'; return "&quot;";
case '<': case "<":
return '&lt;'; return "&lt;";
case '>': case ">":
return '&gt;'; return "&gt;";
case '&': case "&":
return '&amp;'; return "&amp;";
} }
}); });
} }
...@@ -1419,7 +1452,7 @@ function process( last ) { ...@@ -1419,7 +1452,7 @@ function process( last ) {
if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) { if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) {
config.queue.shift()(); config.queue.shift()();
} else { } else {
window.setTimeout( next, 13 ); setTimeout( next, 13 );
break; break;
} }
} }
...@@ -1434,11 +1467,13 @@ function saveGlobal() { ...@@ -1434,11 +1467,13 @@ function saveGlobal() {
if ( config.noglobals ) { if ( config.noglobals ) {
for ( var key in window ) { for ( var key in window ) {
// in Opera sometimes DOM element ids show up here, ignore them if ( hasOwn.call( window, key ) ) {
if ( !hasOwn.call( window, key ) || /^qunit-test-output/.test( key ) ) { // in Opera sometimes DOM element ids show up here, ignore them
continue; if ( /^qunit-test-output/.test( key ) ) {
continue;
}
config.pollution.push( key );
} }
config.pollution.push( key );
} }
} }
} }
...@@ -1480,12 +1515,15 @@ function diff( a, b ) { ...@@ -1480,12 +1515,15 @@ function diff( a, b ) {
function extend( a, b ) { function extend( a, b ) {
for ( var prop in b ) { for ( var prop in b ) {
if ( b[ prop ] === undefined ) { if ( hasOwn.call( b, prop ) ) {
delete a[ prop ]; // Avoid "Member not found" error in IE8 caused by messing with window.constructor
if ( !( prop === "constructor" && a === window ) ) {
// Avoid "Member not found" error in IE8 caused by setting window.constructor if ( b[ prop ] === undefined ) {
} else if ( prop !== "constructor" || a !== window ) { delete a[ prop ];
a[ prop ] = b[ prop ]; } else {
a[ prop ] = b[ prop ];
}
}
} }
} }
...@@ -1535,8 +1573,8 @@ function removeClass( elem, name ) { ...@@ -1535,8 +1573,8 @@ function removeClass( elem, name ) {
while ( set.indexOf(" " + name + " ") > -1 ) { while ( set.indexOf(" " + name + " ") > -1 ) {
set = set.replace(" " + name + " " , " "); set = set.replace(" " + name + " " , " ");
} }
// If possible, trim it for prettiness, but not neccecarily // If possible, trim it for prettiness, but not necessarily
elem.className = window.jQuery ? jQuery.trim( set ) : ( set.trim ? set.trim() : set ); elem.className = typeof set.trim === "function" ? set.trim() : set.replace(/^\s+|\s+$/g, "");
} }
function id( name ) { function id( name ) {
...@@ -1585,8 +1623,10 @@ QUnit.equiv = (function() { ...@@ -1585,8 +1623,10 @@ QUnit.equiv = (function() {
callers = [], callers = [],
// stack to avoiding loops from circular referencing // stack to avoiding loops from circular referencing
parents = [], parents = [],
parentsB = [],
getProto = Object.getPrototypeOf || function ( obj ) { getProto = Object.getPrototypeOf || function ( obj ) {
/*jshint camelcase:false */
return obj.__proto__; return obj.__proto__;
}, },
callbacks = (function () { callbacks = (function () {
...@@ -1595,7 +1635,7 @@ QUnit.equiv = (function() { ...@@ -1595,7 +1635,7 @@ QUnit.equiv = (function() {
function useStrictEquality( b, a ) { function useStrictEquality( b, a ) {
/*jshint eqeqeq:false */ /*jshint eqeqeq:false */
if ( b instanceof a.constructor || a instanceof b.constructor ) { if ( b instanceof a.constructor || a instanceof b.constructor ) {
// to catch short annotaion VS 'new' annotation of a // to catch short annotation VS 'new' annotation of a
// declaration // declaration
// e.g. var i = 1; // e.g. var i = 1;
// var j = new Number(1); // var j = new Number(1);
...@@ -1624,7 +1664,7 @@ QUnit.equiv = (function() { ...@@ -1624,7 +1664,7 @@ QUnit.equiv = (function() {
return QUnit.objectType( b ) === "regexp" && return QUnit.objectType( b ) === "regexp" &&
// the regex itself // the regex itself
a.source === b.source && a.source === b.source &&
// and its modifers // and its modifiers
a.global === b.global && a.global === b.global &&
// (gmi) ... // (gmi) ...
a.ignoreCase === b.ignoreCase && a.ignoreCase === b.ignoreCase &&
...@@ -1641,7 +1681,7 @@ QUnit.equiv = (function() { ...@@ -1641,7 +1681,7 @@ QUnit.equiv = (function() {
}, },
"array": function( b, a ) { "array": function( b, a ) {
var i, j, len, loop; var i, j, len, loop, aCircular, bCircular;
// b could be an object literal here // b could be an object literal here
if ( QUnit.objectType( b ) !== "array" ) { if ( QUnit.objectType( b ) !== "array" ) {
...@@ -1656,24 +1696,36 @@ QUnit.equiv = (function() { ...@@ -1656,24 +1696,36 @@ QUnit.equiv = (function() {
// track reference to avoid circular references // track reference to avoid circular references
parents.push( a ); parents.push( a );
parentsB.push( b );
for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
loop = false; loop = false;
for ( j = 0; j < parents.length; j++ ) { for ( j = 0; j < parents.length; j++ ) {
if ( parents[j] === a[i] ) { aCircular = parents[j] === a[i];
loop = true;// dont rewalk array bCircular = parentsB[j] === b[i];
if ( aCircular || bCircular ) {
if ( a[i] === b[i] || aCircular && bCircular ) {
loop = true;
} else {
parents.pop();
parentsB.pop();
return false;
}
} }
} }
if ( !loop && !innerEquiv(a[i], b[i]) ) { if ( !loop && !innerEquiv(a[i], b[i]) ) {
parents.pop(); parents.pop();
parentsB.pop();
return false; return false;
} }
} }
parents.pop(); parents.pop();
parentsB.pop();
return true; return true;
}, },
"object": function( b, a ) { "object": function( b, a ) {
var i, j, loop, /*jshint forin:false */
var i, j, loop, aCircular, bCircular,
// Default to true // Default to true
eq = true, eq = true,
aProperties = [], aProperties = [],
...@@ -1692,28 +1744,36 @@ QUnit.equiv = (function() { ...@@ -1692,28 +1744,36 @@ QUnit.equiv = (function() {
// stack constructor before traversing properties // stack constructor before traversing properties
callers.push( a.constructor ); callers.push( a.constructor );
// track reference to avoid circular references // track reference to avoid circular references
parents.push( a ); parents.push( a );
parentsB.push( b );
for ( i in a ) { // be strict: don't ensures hasOwnProperty // be strict: don't ensure hasOwnProperty and go deep
// and go deep for ( i in a ) {
loop = false; loop = false;
for ( j = 0; j < parents.length; j++ ) { for ( j = 0; j < parents.length; j++ ) {
if ( parents[j] === a[i] ) { aCircular = parents[j] === a[i];
// don't go down the same path twice bCircular = parentsB[j] === b[i];
loop = true; if ( aCircular || bCircular ) {
if ( a[i] === b[i] || aCircular && bCircular ) {
loop = true;
} else {
eq = false;
break;
}
} }
} }
aProperties.push(i); // collect a's properties aProperties.push(i);
if ( !loop && !innerEquiv(a[i], b[i]) ) {
if (!loop && !innerEquiv( a[i], b[i] ) ) {
eq = false; eq = false;
break; break;
} }
} }
callers.pop(); // unstack, we are done
parents.pop(); parents.pop();
parentsB.pop();
callers.pop(); // unstack, we are done
for ( i in b ) { for ( i in b ) {
bProperties.push( i ); // collect b's properties bProperties.push( i ); // collect b's properties
...@@ -1743,7 +1803,7 @@ QUnit.equiv = (function() { ...@@ -1743,7 +1803,7 @@ QUnit.equiv = (function() {
} }
// apply transition with (1..n) arguments // apply transition with (1..n) arguments
}( args[0], args[1] ) && arguments.callee.apply( this, args.splice(1, args.length - 1 )) ); }( args[0], args[1] ) && innerEquiv.apply( this, args.splice(1, args.length - 1 )) );
}; };
return innerEquiv; return innerEquiv;
...@@ -1761,7 +1821,7 @@ QUnit.equiv = (function() { ...@@ -1761,7 +1821,7 @@ QUnit.equiv = (function() {
*/ */
QUnit.jsDump = (function() { QUnit.jsDump = (function() {
function quote( str ) { function quote( str ) {
return '"' + str.toString().replace( /"/g, '\\"' ) + '"'; return "\"" + str.toString().replace( /"/g, "\\\"" ) + "\"";
} }
function literal( o ) { function literal( o ) {
return o + ""; return o + "";
...@@ -1854,13 +1914,13 @@ QUnit.jsDump = (function() { ...@@ -1854,13 +1914,13 @@ QUnit.jsDump = (function() {
if ( this.HTML ) { if ( this.HTML ) {
chr = chr.replace( /\t/g, " " ).replace( / /g, "&nbsp;" ); chr = chr.replace( /\t/g, " " ).replace( / /g, "&nbsp;" );
} }
return new Array( this._depth_ + (extra||0) ).join(chr); return new Array( this.depth + ( extra || 0 ) ).join(chr);
}, },
up: function( a ) { up: function( a ) {
this._depth_ += a || 1; this.depth += a || 1;
}, },
down: function( a ) { down: function( a ) {
this._depth_ -= a || 1; this.depth -= a || 1;
}, },
setParser: function( name, parser ) { setParser: function( name, parser ) {
this.parsers[name] = parser; this.parsers[name] = parser;
...@@ -1870,7 +1930,7 @@ QUnit.jsDump = (function() { ...@@ -1870,7 +1930,7 @@ QUnit.jsDump = (function() {
literal: literal, literal: literal,
join: join, join: join,
// //
_depth_: 1, depth: 1,
// This is the list of parsers, to modify them, use jsDump.setParser // This is the list of parsers, to modify them, use jsDump.setParser
parsers: { parsers: {
window: "[Window]", window: "[Window]",
...@@ -1898,6 +1958,7 @@ QUnit.jsDump = (function() { ...@@ -1898,6 +1958,7 @@ QUnit.jsDump = (function() {
nodelist: array, nodelist: array,
"arguments": array, "arguments": array,
object: function( map, stack ) { object: function( map, stack ) {
/*jshint forin:false */
var ret = [ ], keys, key, val, i; var ret = [ ], keys, key, val, i;
QUnit.jsDump.up(); QUnit.jsDump.up();
keys = []; keys = [];
...@@ -2036,18 +2097,17 @@ QUnit.diff = (function() { ...@@ -2036,18 +2097,17 @@ QUnit.diff = (function() {
} }
for ( i in ns ) { for ( i in ns ) {
if ( !hasOwn.call( ns, i ) ) { if ( hasOwn.call( ns, i ) ) {
continue; if ( ns[i].rows.length === 1 && hasOwn.call( os, i ) && os[i].rows.length === 1 ) {
} n[ ns[i].rows[0] ] = {
if ( ns[i].rows.length === 1 && hasOwn.call( os, i ) && os[i].rows.length === 1 ) { text: n[ ns[i].rows[0] ],
n[ ns[i].rows[0] ] = { row: os[i].rows[0]
text: n[ ns[i].rows[0] ], };
row: os[i].rows[0] o[ os[i].rows[0] ] = {
}; text: o[ os[i].rows[0] ],
o[ os[i].rows[0] ] = { row: ns[i].rows[0]
text: o[ os[i].rows[0] ], };
row: ns[i].rows[0] }
};
} }
} }
...@@ -2143,9 +2203,9 @@ QUnit.diff = (function() { ...@@ -2143,9 +2203,9 @@ QUnit.diff = (function() {
}; };
}()); }());
// for CommonJS enviroments, export everything // for CommonJS environments, export everything
if ( typeof exports !== "undefined" ) { if ( typeof exports !== "undefined" ) {
extend( exports, QUnit ); extend( exports, QUnit.constructor.prototype );
} }
// get at whatever the global object is, like window in browsers // get at whatever the global object is, like window in browsers
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment