mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Build: Update jscs and lint files
Fixes gh-2056
This commit is contained in:
1854
test/data/jquery-1.9.1.js
vendored
1854
test/data/jquery-1.9.1.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
||||
// Simple script loader that uses jQuery.readyWait via jQuery.holdReady()
|
||||
|
||||
//Hold on jQuery!
|
||||
jQuery.holdReady(true);
|
||||
jQuery.holdReady( true );
|
||||
|
||||
var readyRegExp = /^(complete|loaded)$/;
|
||||
|
||||
function assetLoaded( evt ){
|
||||
function assetLoaded( evt ) {
|
||||
var node = evt.currentTarget || evt.srcElement;
|
||||
if ( evt.type === "load" || readyRegExp.test(node.readyState) ) {
|
||||
jQuery.holdReady(false);
|
||||
if ( evt.type === "load" || readyRegExp.test( node.readyState ) ) {
|
||||
jQuery.holdReady( false );
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout( function() {
|
||||
var script = document.createElement("script");
|
||||
var script = document.createElement( "script" );
|
||||
script.type = "text/javascript";
|
||||
if ( script.addEventListener ) {
|
||||
script.addEventListener( "load", assetLoaded, false );
|
||||
@@ -21,5 +21,5 @@ setTimeout( function() {
|
||||
script.attachEvent( "onreadystatechange", assetLoaded );
|
||||
}
|
||||
script.src = "data/readywaitasset.js";
|
||||
document.getElementsByTagName("head")[0].appendChild(script);
|
||||
document.getElementsByTagName( "head" )[ 0 ].appendChild( script );
|
||||
}, 2000 );
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
var fireNative, originaljQuery, original$,
|
||||
baseURL = "",
|
||||
supportjQuery = this.jQuery,
|
||||
|
||||
// see RFC 2606
|
||||
externalHost = "example.com";
|
||||
|
||||
@@ -24,7 +25,7 @@ this.q = function() {
|
||||
i = 0;
|
||||
|
||||
for ( ; i < arguments.length; i++ ) {
|
||||
r.push( document.getElementById( arguments[i] ) );
|
||||
r.push( document.getElementById( arguments[ i ] ) );
|
||||
}
|
||||
return r;
|
||||
};
|
||||
@@ -62,7 +63,7 @@ this.createDashboardXML = function() {
|
||||
</locations> \
|
||||
</dashboard>';
|
||||
|
||||
return jQuery.parseXML(string);
|
||||
return jQuery.parseXML( string );
|
||||
};
|
||||
|
||||
this.createWithFriesXML = function() {
|
||||
@@ -131,7 +132,7 @@ fireNative = document.createEvent ?
|
||||
* @result "data/test.php?foo=bar&10538358345554"
|
||||
*/
|
||||
function url( value ) {
|
||||
return baseURL + value + (/\?/.test( value ) ? "&" : "?") +
|
||||
return baseURL + value + ( /\?/.test( value ) ? "&" : "?" ) +
|
||||
new Date().getTime() + "" + parseInt( Math.random() * 100000, 10 );
|
||||
}
|
||||
|
||||
@@ -166,7 +167,7 @@ this.ajaxTest = function( title, expect, options ) {
|
||||
}
|
||||
|
||||
// Make sure all events will be called before done()
|
||||
setTimeout(done);
|
||||
setTimeout( done );
|
||||
}
|
||||
},
|
||||
requests = jQuery.map( requestOptions, function( options ) {
|
||||
@@ -192,7 +193,7 @@ this.ajaxTest = function( title, expect, options ) {
|
||||
.done( callIfDefined( "done", "success" ) )
|
||||
.fail( callIfDefined( "fail", "error" ) )
|
||||
.always( complete );
|
||||
});
|
||||
} );
|
||||
|
||||
ajaxTest.abort = function( reason ) {
|
||||
if ( !completed ) {
|
||||
@@ -201,20 +202,20 @@ this.ajaxTest = function( title, expect, options ) {
|
||||
ok( false, "aborted " + reason );
|
||||
jQuery.each( requests, function( i, request ) {
|
||||
request.abort();
|
||||
});
|
||||
} );
|
||||
}
|
||||
};
|
||||
});
|
||||
} );
|
||||
};
|
||||
|
||||
this.testIframe = function( fileName, name, fn ) {
|
||||
QUnit.test(name, function( assert ) {
|
||||
QUnit.test( name, function( assert ) {
|
||||
var done = assert.async();
|
||||
|
||||
// load fixture in iframe
|
||||
var iframe = loadFixture(),
|
||||
win = iframe.contentWindow,
|
||||
interval = setInterval(function() {
|
||||
interval = setInterval( function() {
|
||||
if ( win && win.jQuery && win.jQuery.isReady ) {
|
||||
clearInterval( interval );
|
||||
|
||||
@@ -225,7 +226,7 @@ this.testIframe = function( fileName, name, fn ) {
|
||||
iframe = null;
|
||||
}
|
||||
}, 15 );
|
||||
});
|
||||
} );
|
||||
|
||||
function loadFixture() {
|
||||
var src = url( "./data/" + fileName + ".html" ),
|
||||
@@ -248,7 +249,7 @@ this.testIframeWithCallback = function( title, fileName, func ) {
|
||||
|
||||
args.push( assert );
|
||||
|
||||
setTimeout(function() {
|
||||
setTimeout( function() {
|
||||
this.iframeCallback = undefined;
|
||||
|
||||
iframe.remove();
|
||||
@@ -256,12 +257,12 @@ this.testIframeWithCallback = function( title, fileName, func ) {
|
||||
func = function() {};
|
||||
|
||||
done();
|
||||
});
|
||||
} );
|
||||
};
|
||||
iframe = jQuery( "<div/>" ).css({ position: "absolute", width: "500px", left: "-600px" })
|
||||
iframe = jQuery( "<div/>" ).css( { position: "absolute", width: "500px", left: "-600px" } )
|
||||
.append( jQuery( "<iframe/>" ).attr( "src", url( "./data/" + fileName ) ) )
|
||||
.appendTo( "#qunit-fixture" );
|
||||
});
|
||||
} );
|
||||
};
|
||||
this.iframeCallback = undefined;
|
||||
|
||||
@@ -275,7 +276,7 @@ this.loadTests = function() {
|
||||
loadSwarm = url && url.indexOf( "http" ) === 0;
|
||||
|
||||
// Get testSubproject from testrunner first
|
||||
require([ "data/testrunner.js" ], function() {
|
||||
require( [ "data/testrunner.js" ], function() {
|
||||
var tests = [
|
||||
"unit/core.js",
|
||||
"unit/callbacks.js",
|
||||
@@ -300,7 +301,7 @@ this.loadTests = function() {
|
||||
];
|
||||
|
||||
// Ensure load order (to preserve test numbers)
|
||||
(function loadDep() {
|
||||
( function loadDep() {
|
||||
var dep = tests.shift();
|
||||
|
||||
if ( dep ) {
|
||||
@@ -318,14 +319,14 @@ this.loadTests = function() {
|
||||
|
||||
// Load the TestSwarm listener if swarmURL is in the address.
|
||||
if ( loadSwarm ) {
|
||||
require( [ "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() ],
|
||||
require( [ "http://swarm.jquery.org/js/inject.js?" + ( new Date() ).getTime() ],
|
||||
function() {
|
||||
QUnit.start();
|
||||
});
|
||||
} );
|
||||
} else {
|
||||
QUnit.start();
|
||||
}
|
||||
}
|
||||
})();
|
||||
});
|
||||
} )();
|
||||
} );
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(function() {
|
||||
( function() {
|
||||
|
||||
// Store the old counts so that we only assert on tests that have actually leaked,
|
||||
// instead of asserting every time a test has leaked sometime in the past
|
||||
@@ -49,6 +49,7 @@ QUnit.expectJqData = function( env, elems, key ) {
|
||||
// be available as long as the object is not garbage collected by
|
||||
// the js engine, and when it is, the data will be removed with it.
|
||||
if ( !elem.nodeType ) {
|
||||
|
||||
// Fixes false positives for dataTests(window), dataTests({}).
|
||||
continue;
|
||||
}
|
||||
@@ -56,6 +57,7 @@ QUnit.expectJqData = function( env, elems, key ) {
|
||||
expando = elem[ jQuery.expando ];
|
||||
|
||||
if ( expando === undefined ) {
|
||||
|
||||
// In this case the element exists fine, but
|
||||
// jQuery.data (or internal data) was never (in)directly
|
||||
// called.
|
||||
@@ -79,12 +81,12 @@ QUnit.expectJqData = function( env, elems, key ) {
|
||||
}
|
||||
|
||||
};
|
||||
QUnit.config.urlConfig.push({
|
||||
QUnit.config.urlConfig.push( {
|
||||
id: "jqdata",
|
||||
label: "Always check jQuery.data",
|
||||
tooltip: "Trigger QUnit.expectJqData detection for all tests " +
|
||||
"instead of just the ones that call it"
|
||||
});
|
||||
} );
|
||||
|
||||
/**
|
||||
* Ensures that tests have cleaned up properly after themselves. Should be passed as the
|
||||
@@ -106,6 +108,7 @@ window.moduleTeardown = function() {
|
||||
delete jQuery.cache[ i ];
|
||||
delete expectedDataKeys[ i ];
|
||||
}
|
||||
|
||||
// In case it was removed from cache before (or never there in the first place)
|
||||
for ( i in expectedDataKeys ) {
|
||||
deepEqual(
|
||||
@@ -129,7 +132,7 @@ window.moduleTeardown = function() {
|
||||
if ( jQuery.active !== undefined && jQuery.active !== oldActive ) {
|
||||
equal( jQuery.active, oldActive, "No AJAX requests are still active" );
|
||||
if ( ajaxTest.abort ) {
|
||||
ajaxTest.abort("active requests");
|
||||
ajaxTest.abort( "active requests" );
|
||||
}
|
||||
oldActive = jQuery.active;
|
||||
}
|
||||
@@ -150,15 +153,17 @@ window.moduleTeardown = function() {
|
||||
}
|
||||
};
|
||||
|
||||
QUnit.done(function() {
|
||||
QUnit.done( function() {
|
||||
|
||||
// Remove our own fixtures outside #qunit-fixture
|
||||
supportjQuery( "#qunit ~ *" ).remove();
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.testDone(function() {
|
||||
QUnit.testDone( function() {
|
||||
|
||||
// Ensure jQuery events and data on the fixture are properly removed
|
||||
jQuery( "#qunit-fixture" ).empty();
|
||||
|
||||
// ...even if the jQuery under test has a broken .empty()
|
||||
supportjQuery( "#qunit-fixture" ).empty();
|
||||
|
||||
@@ -172,10 +177,10 @@ QUnit.testDone(function() {
|
||||
|
||||
// Cleanup globals
|
||||
Globals.cleanup();
|
||||
});
|
||||
} );
|
||||
|
||||
// Register globals for cleanup and the cleanup code itself
|
||||
window.Globals = (function() {
|
||||
window.Globals = ( function() {
|
||||
var globals = {};
|
||||
|
||||
return {
|
||||
@@ -193,6 +198,6 @@ window.Globals = (function() {
|
||||
globals = {};
|
||||
}
|
||||
};
|
||||
})();
|
||||
} )();
|
||||
|
||||
})();
|
||||
} )();
|
||||
|
||||
@@ -4,7 +4,7 @@ var assert = require( "assert" ),
|
||||
ensureGlobalNotCreated = require( "./lib/ensure_global_not_created" ),
|
||||
jQueryFactory = require( "../../dist/jquery.js" );
|
||||
|
||||
assert.throws( function () {
|
||||
assert.throws( function() {
|
||||
jQueryFactory( {} );
|
||||
}, /jQuery requires a window with a document/ );
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
QUnit.module( "callbacks", {
|
||||
teardown: moduleTeardown
|
||||
});
|
||||
} );
|
||||
|
||||
(function() {
|
||||
( function() {
|
||||
|
||||
var output,
|
||||
addToOutput = function( string ) {
|
||||
@@ -10,9 +10,9 @@ var output,
|
||||
output += string;
|
||||
};
|
||||
},
|
||||
outputA = addToOutput("A"),
|
||||
outputB = addToOutput("B"),
|
||||
outputC = addToOutput("C"),
|
||||
outputA = addToOutput( "A" ),
|
||||
outputB = addToOutput( "B" ),
|
||||
outputC = addToOutput( "C" ),
|
||||
tests = {
|
||||
"": "XABC X XABCABCC X XBB X XABA X XX",
|
||||
"once": "XABC X X X X X XABA X XX",
|
||||
@@ -54,11 +54,11 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
if ( this.length ) {
|
||||
objectFlags[ this ] = true;
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.each( filters, function( filterLabel ) {
|
||||
|
||||
jQuery.each({
|
||||
jQuery.each( {
|
||||
"string": strFlags,
|
||||
"object": objectFlags
|
||||
}, function( flagsTypes, flags ) {
|
||||
@@ -76,20 +76,20 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
assert.strictEqual( cblist.locked(), false, ".locked() initially false" );
|
||||
assert.strictEqual( cblist.disabled(), false, ".disabled() initially false" );
|
||||
assert.strictEqual( cblist.fired(), false, ".fired() initially false" );
|
||||
cblist.add(function( str ) {
|
||||
cblist.add( function( str ) {
|
||||
output += str;
|
||||
});
|
||||
} );
|
||||
assert.strictEqual( cblist.fired(), false, ".fired() still false after .add" );
|
||||
cblist.fire( "A" );
|
||||
assert.strictEqual( output, "XA", "Basic binding and firing" );
|
||||
assert.strictEqual( cblist.fired(), true, ".fired() detects firing" );
|
||||
output = "X";
|
||||
cblist.disable();
|
||||
cblist.add(function( str ) {
|
||||
cblist.add( function( str ) {
|
||||
output += str;
|
||||
});
|
||||
} );
|
||||
assert.strictEqual( output, "X", "Adding a callback after disabling" );
|
||||
cblist.fire("A");
|
||||
cblist.fire( "A" );
|
||||
assert.strictEqual( output, "X", "Firing after disabling" );
|
||||
assert.strictEqual( cblist.disabled(), true, ".disabled() becomes true" );
|
||||
assert.strictEqual( cblist.locked(), true, "disabling locks" );
|
||||
@@ -113,20 +113,20 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
// Basic binding and firing (context, arguments)
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add(function() {
|
||||
cblist.add( function() {
|
||||
assert.equal( this, window, "Basic binding and firing (context)" );
|
||||
output += Array.prototype.join.call( arguments, "" );
|
||||
});
|
||||
} );
|
||||
cblist.fireWith( window, [ "A", "B" ] );
|
||||
assert.strictEqual( output, "XAB", "Basic binding and firing (arguments)" );
|
||||
|
||||
// fireWith with no arguments
|
||||
output = "";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add(function() {
|
||||
cblist.add( function() {
|
||||
assert.equal( this, window, "fireWith with no arguments (context is window)" );
|
||||
assert.strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" );
|
||||
});
|
||||
} );
|
||||
cblist.fireWith();
|
||||
|
||||
// Basic binding, removing and firing
|
||||
@@ -150,17 +150,17 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
// Locking
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add(function( str ) {
|
||||
cblist.add( function( str ) {
|
||||
output += str;
|
||||
});
|
||||
} );
|
||||
cblist.lock();
|
||||
cblist.add(function( str ) {
|
||||
cblist.add( function( str ) {
|
||||
output += str;
|
||||
});
|
||||
cblist.fire("A");
|
||||
cblist.add(function( str ) {
|
||||
} );
|
||||
cblist.fire( "A" );
|
||||
cblist.add( function( str ) {
|
||||
output += str;
|
||||
});
|
||||
} );
|
||||
assert.strictEqual( output, "X", "Lock early" );
|
||||
assert.strictEqual( cblist.locked(), true, "Locking reflected in accessor" );
|
||||
|
||||
@@ -168,16 +168,16 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add( cblist.lock );
|
||||
cblist.add(function( str ) {
|
||||
cblist.add( function( str ) {
|
||||
output += str;
|
||||
});
|
||||
} );
|
||||
cblist.fire( "A" );
|
||||
assert.strictEqual( output, "XA", "Locking doesn't abort execution (gh-1990)" );
|
||||
|
||||
// Ordering
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add(function() {
|
||||
cblist.add( function() {
|
||||
cblist.add( outputC );
|
||||
outputA();
|
||||
}, outputB );
|
||||
@@ -186,7 +186,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
|
||||
// Add and fire again
|
||||
output = "X";
|
||||
cblist.add(function() {
|
||||
cblist.add( function() {
|
||||
cblist.add( outputC );
|
||||
outputA();
|
||||
}, outputB );
|
||||
@@ -199,23 +199,23 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
// Multiple fire
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add(function( str ) {
|
||||
cblist.add( function( str ) {
|
||||
output += str;
|
||||
});
|
||||
cblist.fire("A");
|
||||
} );
|
||||
cblist.fire( "A" );
|
||||
assert.strictEqual( output, "XA", "Multiple fire (first fire)" );
|
||||
output = "X";
|
||||
cblist.add(function( str ) {
|
||||
cblist.add( function( str ) {
|
||||
output += str;
|
||||
});
|
||||
} );
|
||||
assert.strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
|
||||
output = "X";
|
||||
cblist.fire("B");
|
||||
cblist.fire( "B" );
|
||||
assert.strictEqual( output, results.shift(), "Multiple fire (second fire)" );
|
||||
output = "X";
|
||||
cblist.add(function( str ) {
|
||||
cblist.add( function( str ) {
|
||||
output += str;
|
||||
});
|
||||
} );
|
||||
assert.strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
|
||||
|
||||
// Return false
|
||||
@@ -244,12 +244,12 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
cblist.add( handler );
|
||||
cblist.fire();
|
||||
assert.strictEqual( output, results.shift(), "No callback iteration" );
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
})();
|
||||
} )();
|
||||
|
||||
QUnit.test( "jQuery.Callbacks( options ) - options are copied", function( assert ) {
|
||||
|
||||
@@ -263,25 +263,25 @@ QUnit.test( "jQuery.Callbacks( options ) - options are copied", function( assert
|
||||
fn = function() {
|
||||
assert.ok( !( count++ ), "called once" );
|
||||
};
|
||||
options["unique"] = false;
|
||||
options[ "unique" ] = false;
|
||||
cb.add( fn, fn );
|
||||
cb.fire();
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Callbacks.fireWith - arguments are copied", function( assert ) {
|
||||
|
||||
assert.expect( 1 );
|
||||
|
||||
var cb = jQuery.Callbacks("memory"),
|
||||
args = ["hello"];
|
||||
var cb = jQuery.Callbacks( "memory" ),
|
||||
args = [ "hello" ];
|
||||
|
||||
cb.fireWith( null, args );
|
||||
args[ 0 ] = "world";
|
||||
|
||||
cb.add(function( hello ) {
|
||||
cb.add( function( hello ) {
|
||||
assert.strictEqual( hello, "hello", "arguments are copied internally" );
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Callbacks.remove - should remove all instances", function( assert ) {
|
||||
|
||||
@@ -295,8 +295,8 @@ QUnit.test( "jQuery.Callbacks.remove - should remove all instances", function( a
|
||||
|
||||
cb.add( fn, fn, function() {
|
||||
assert.ok( true, "end of test" );
|
||||
}).remove( fn ).fire();
|
||||
});
|
||||
} ).remove( fn ).fire();
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Callbacks.has", function( assert ) {
|
||||
|
||||
@@ -312,36 +312,36 @@ QUnit.test( "jQuery.Callbacks.has", function( assert ) {
|
||||
function getC() {
|
||||
return "C";
|
||||
}
|
||||
cb.add(getA, getB, getC);
|
||||
cb.add( getA, getB, getC );
|
||||
assert.strictEqual( cb.has(), true, "No arguments to .has() returns whether callback function(s) are attached or not" );
|
||||
assert.strictEqual( cb.has(getA), true, "Check if a specific callback function is in the Callbacks list" );
|
||||
assert.strictEqual( cb.has( getA ), true, "Check if a specific callback function is in the Callbacks list" );
|
||||
|
||||
cb.remove(getB);
|
||||
assert.strictEqual( cb.has(getB), false, "Remove a specific callback function and make sure its no longer there" );
|
||||
assert.strictEqual( cb.has(getA), true, "Remove a specific callback function and make sure other callback function is still there" );
|
||||
cb.remove( getB );
|
||||
assert.strictEqual( cb.has( getB ), false, "Remove a specific callback function and make sure its no longer there" );
|
||||
assert.strictEqual( cb.has( getA ), true, "Remove a specific callback function and make sure other callback function is still there" );
|
||||
|
||||
cb.empty();
|
||||
assert.strictEqual( cb.has(), false, "Empty list and make sure there are no callback function(s)" );
|
||||
assert.strictEqual( cb.has(getA), false, "Check for a specific function in an empty() list" );
|
||||
assert.strictEqual( cb.has( getA ), false, "Check for a specific function in an empty() list" );
|
||||
|
||||
cb.add(getA, getB, function(){
|
||||
cb.add( getA, getB, function() {
|
||||
assert.strictEqual( cb.has(), true, "Check if list has callback function(s) from within a callback function" );
|
||||
assert.strictEqual( cb.has(getA), true, "Check if list has a specific callback from within a callback function" );
|
||||
}).fire();
|
||||
assert.strictEqual( cb.has( getA ), true, "Check if list has a specific callback from within a callback function" );
|
||||
} ).fire();
|
||||
|
||||
assert.strictEqual( cb.has(), true, "Callbacks list has callback function(s) after firing" );
|
||||
|
||||
cb.disable();
|
||||
assert.strictEqual( cb.has(), false, "disabled() list has no callback functions (returns false)" );
|
||||
assert.strictEqual( cb.has(getA), false, "Check for a specific function in a disabled() list" );
|
||||
assert.strictEqual( cb.has( getA ), false, "Check for a specific function in a disabled() list" );
|
||||
|
||||
cb = jQuery.Callbacks("unique");
|
||||
cb.add(getA);
|
||||
cb.add(getA);
|
||||
cb = jQuery.Callbacks( "unique" );
|
||||
cb.add( getA );
|
||||
cb.add( getA );
|
||||
assert.strictEqual( cb.has(), true, "Check if unique list has callback function(s) attached" );
|
||||
cb.lock();
|
||||
assert.strictEqual( cb.has(), false, "locked() list is empty and returns false" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow", function( assert ) {
|
||||
|
||||
@@ -350,7 +350,7 @@ QUnit.test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow
|
||||
jQuery.Callbacks().add( "hello world" );
|
||||
|
||||
assert.ok( true, "no stack overflow" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", function( assert ) {
|
||||
|
||||
@@ -365,4 +365,4 @@ QUnit.test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", fun
|
||||
cb.add( shot );
|
||||
cb.fire();
|
||||
assert.ok( !fired, "Disabled callback function didn't fire" );
|
||||
});
|
||||
} );
|
||||
|
||||
1000
test/unit/core.js
1000
test/unit/core.js
File diff suppressed because it is too large
Load Diff
866
test/unit/css.js
866
test/unit/css.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
QUnit.module( "deferred", {
|
||||
teardown: moduleTeardown
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
|
||||
@@ -16,32 +16,32 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
|
||||
assert.ok( jQuery.isFunction( defer.pipe ), "defer.pipe is a function" );
|
||||
|
||||
createDeferred().resolve().done(function() {
|
||||
createDeferred().resolve().done( function() {
|
||||
assert.ok( true, "Success on resolve" );
|
||||
assert.strictEqual( this.state(), "resolved", "Deferred is resolved (state)" );
|
||||
}).fail(function() {
|
||||
} ).fail( function() {
|
||||
assert.ok( false, "Error on resolve" );
|
||||
}).always(function() {
|
||||
} ).always( function() {
|
||||
assert.ok( true, "Always callback on resolve" );
|
||||
});
|
||||
} );
|
||||
|
||||
createDeferred().reject().done(function() {
|
||||
createDeferred().reject().done( function() {
|
||||
assert.ok( false, "Success on reject" );
|
||||
}).fail(function() {
|
||||
} ).fail( function() {
|
||||
assert.ok( true, "Error on reject" );
|
||||
assert.strictEqual( this.state(), "rejected", "Deferred is rejected (state)" );
|
||||
}).always(function() {
|
||||
} ).always( function() {
|
||||
assert.ok( true, "Always callback on reject" );
|
||||
});
|
||||
} );
|
||||
|
||||
createDeferred(function( defer ) {
|
||||
createDeferred( function( defer ) {
|
||||
assert.ok( this === defer, "Defer passed as this & first argument" );
|
||||
this.resolve("done");
|
||||
}).done(function( value ) {
|
||||
this.resolve( "done" );
|
||||
} ).done( function( value ) {
|
||||
assert.strictEqual( value, "done", "Passed function executed" );
|
||||
});
|
||||
} );
|
||||
|
||||
createDeferred(function( defer ) {
|
||||
createDeferred( function( defer ) {
|
||||
var promise = defer.promise(),
|
||||
func = function() {},
|
||||
funcPromise = defer.promise( func );
|
||||
@@ -54,17 +54,17 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
if ( promise[ key ] !== func[ key ] ) {
|
||||
assert.strictEqual( func[ key ], promise[ key ], key + " is the same" );
|
||||
}
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach( "resolve reject".split(" "), function( _, change ) {
|
||||
createDeferred(function( defer ) {
|
||||
jQuery.expandedEach( "resolve reject".split( " " ), function( _, change ) {
|
||||
createDeferred( function( defer ) {
|
||||
assert.strictEqual( defer.state(), "pending", "pending after creation" );
|
||||
var checked = 0;
|
||||
defer.progress(function( value ) {
|
||||
defer.progress( function( value ) {
|
||||
assert.strictEqual( value, checked, "Progress: right value (" + value + ") received" );
|
||||
});
|
||||
} );
|
||||
for ( checked = 0; checked < 3; checked++ ) {
|
||||
defer.notify( checked );
|
||||
}
|
||||
@@ -72,11 +72,10 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
defer[ change ]();
|
||||
assert.notStrictEqual( defer.state(), "pending", "not pending after " + change );
|
||||
defer.notify();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred - chainability", function( assert ) {
|
||||
|
||||
@@ -85,13 +84,13 @@ QUnit.test( "jQuery.Deferred - chainability", function( assert ) {
|
||||
assert.expect( 10 );
|
||||
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach( "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split(" "), function( _, method ) {
|
||||
jQuery.expandedEach( "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split( " " ), function( _, method ) {
|
||||
var object = {
|
||||
m: defer[ method ]
|
||||
};
|
||||
assert.strictEqual( object.m(), object, method + " is chainable" );
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - filtering (done)", function( assert ) {
|
||||
|
||||
@@ -99,36 +98,36 @@ QUnit.test( "jQuery.Deferred.then - filtering (done)", function( assert ) {
|
||||
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then(function( a, b ) {
|
||||
piped = defer.then( function( a, b ) {
|
||||
return a * b;
|
||||
}),
|
||||
} ),
|
||||
done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
|
||||
|
||||
piped.done(function( result ) {
|
||||
piped.done( function( result ) {
|
||||
value3 = result;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.done(function( a, b ) {
|
||||
defer.done( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.resolve( 2, 3 ).then(function() {
|
||||
defer.resolve( 2, 3 ).then( function() {
|
||||
assert.strictEqual( value1, 2, "first resolve value ok" );
|
||||
assert.strictEqual( value2, 3, "second resolve value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.Deferred().reject().then(function() {
|
||||
jQuery.Deferred().reject().then( function() {
|
||||
assert.ok( false, "then should not be called on reject" );
|
||||
}).then( null, done.pop() );
|
||||
} ).then( null, done.pop() );
|
||||
|
||||
jQuery.Deferred().resolve().then( jQuery.noop ).done(function( value ) {
|
||||
jQuery.Deferred().resolve().then( jQuery.noop ).done( function( value ) {
|
||||
assert.strictEqual( value, undefined, "then done callback can return undefined/null" );
|
||||
done.pop().call();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - filtering (fail)", function( assert ) {
|
||||
|
||||
@@ -138,70 +137,70 @@ QUnit.test( "jQuery.Deferred.then - filtering (fail)", function( assert ) {
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then( null, function( a, b ) {
|
||||
return a * b;
|
||||
}),
|
||||
} ),
|
||||
done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
|
||||
|
||||
piped.done(function( result ) {
|
||||
piped.done( function( result ) {
|
||||
value3 = result;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.fail(function( a, b ) {
|
||||
defer.fail( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.reject( 2, 3 ).then( null, function() {
|
||||
assert.strictEqual( value1, 2, "first reject value ok" );
|
||||
assert.strictEqual( value2, 3, "second reject value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.Deferred().resolve().then( null, function() {
|
||||
assert.ok( false, "then should not be called on resolve" );
|
||||
}).then( done.pop() );
|
||||
} ).then( done.pop() );
|
||||
|
||||
jQuery.Deferred().reject().then( null, jQuery.noop ).done(function( value ) {
|
||||
jQuery.Deferred().reject().then( null, jQuery.noop ).done( function( value ) {
|
||||
assert.strictEqual( value, undefined, "then fail callback can return undefined/null" );
|
||||
done.pop().call();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.catch", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer[ "catch" ](function( a, b ) {
|
||||
piped = defer[ "catch" ]( function( a, b ) {
|
||||
return a * b;
|
||||
}),
|
||||
} ),
|
||||
done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
|
||||
|
||||
piped.done(function( result ) {
|
||||
piped.done( function( result ) {
|
||||
value3 = result;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.fail(function( a, b ) {
|
||||
defer.fail( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.reject( 2, 3 )[ "catch" ](function() {
|
||||
defer.reject( 2, 3 )[ "catch" ]( function() {
|
||||
assert.strictEqual( value1, 2, "first reject value ok" );
|
||||
assert.strictEqual( value2, 3, "second reject value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.Deferred().resolve()[ "catch" ](function() {
|
||||
jQuery.Deferred().resolve()[ "catch" ]( function() {
|
||||
assert.ok( false, "then should not be called on resolve" );
|
||||
}).then( done.pop() );
|
||||
} ).then( done.pop() );
|
||||
|
||||
jQuery.Deferred().reject()[ "catch" ]( jQuery.noop ).done(function( value ) {
|
||||
jQuery.Deferred().reject()[ "catch" ]( jQuery.noop ).done( function( value ) {
|
||||
assert.strictEqual( value, undefined, "then fail callback can return undefined/null" );
|
||||
done.pop().call();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) {
|
||||
|
||||
@@ -211,34 +210,34 @@ QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( ass
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.pipe( null, function( a, b ) {
|
||||
return a * b;
|
||||
}),
|
||||
} ),
|
||||
done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
|
||||
|
||||
piped.fail(function( result ) {
|
||||
piped.fail( function( result ) {
|
||||
value3 = result;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.fail(function( a, b ) {
|
||||
defer.fail( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.reject( 2, 3 ).pipe( null, function() {
|
||||
assert.strictEqual( value1, 2, "first reject value ok" );
|
||||
assert.strictEqual( value2, 3, "second reject value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.Deferred().resolve().pipe( null, function() {
|
||||
assert.ok( false, "then should not be called on resolve" );
|
||||
}).then( done.pop() );
|
||||
} ).then( done.pop() );
|
||||
|
||||
jQuery.Deferred().reject().pipe( null, jQuery.noop ).fail(function( value ) {
|
||||
jQuery.Deferred().reject().pipe( null, jQuery.noop ).fail( function( value ) {
|
||||
assert.strictEqual( value, undefined, "then fail callback can return undefined/null" );
|
||||
done.pop().call();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - filtering (progress)", function( assert ) {
|
||||
|
||||
@@ -248,25 +247,25 @@ QUnit.test( "jQuery.Deferred.then - filtering (progress)", function( assert ) {
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then( null, null, function( a, b ) {
|
||||
return a * b;
|
||||
}),
|
||||
} ),
|
||||
done = assert.async();
|
||||
|
||||
piped.progress(function( result ) {
|
||||
piped.progress( function( result ) {
|
||||
value3 = result;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.progress(function( a, b ) {
|
||||
defer.progress( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.notify( 2, 3 ).then( null, null, function() {
|
||||
assert.strictEqual( value1, 2, "first progress value ok" );
|
||||
assert.strictEqual( value2, 3, "second progress value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
done();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - deferred (done)", function( assert ) {
|
||||
|
||||
@@ -274,31 +273,31 @@ QUnit.test( "jQuery.Deferred.then - deferred (done)", function( assert ) {
|
||||
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then(function( a, b ) {
|
||||
return jQuery.Deferred(function( defer ) {
|
||||
piped = defer.then( function( a, b ) {
|
||||
return jQuery.Deferred( function( defer ) {
|
||||
defer.reject( a * b );
|
||||
});
|
||||
}),
|
||||
} );
|
||||
} ),
|
||||
done = assert.async();
|
||||
|
||||
piped.fail(function( result ) {
|
||||
piped.fail( function( result ) {
|
||||
value3 = result;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.done(function( a, b ) {
|
||||
defer.done( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.resolve( 2, 3 );
|
||||
|
||||
piped.fail(function() {
|
||||
piped.fail( function() {
|
||||
assert.strictEqual( value1, 2, "first resolve value ok" );
|
||||
assert.strictEqual( value2, 3, "second resolve value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
done();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - deferred (fail)", function( assert ) {
|
||||
|
||||
@@ -307,30 +306,30 @@ QUnit.test( "jQuery.Deferred.then - deferred (fail)", function( assert ) {
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then( null, function( a, b ) {
|
||||
return jQuery.Deferred(function( defer ) {
|
||||
return jQuery.Deferred( function( defer ) {
|
||||
defer.resolve( a * b );
|
||||
});
|
||||
}),
|
||||
} );
|
||||
} ),
|
||||
done = assert.async();
|
||||
|
||||
piped.done(function( result ) {
|
||||
piped.done( function( result ) {
|
||||
value3 = result;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.fail(function( a, b ) {
|
||||
defer.fail( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.reject( 2, 3 );
|
||||
|
||||
piped.done(function() {
|
||||
piped.done( function() {
|
||||
assert.strictEqual( value1, 2, "first reject value ok" );
|
||||
assert.strictEqual( value2, 3, "second reject value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
done();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - deferred (progress)", function( assert ) {
|
||||
|
||||
@@ -339,38 +338,38 @@ QUnit.test( "jQuery.Deferred.then - deferred (progress)", function( assert ) {
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then( null, null, function( a, b ) {
|
||||
return jQuery.Deferred(function( defer ) {
|
||||
return jQuery.Deferred( function( defer ) {
|
||||
defer.resolve( a * b );
|
||||
});
|
||||
}),
|
||||
} );
|
||||
} ),
|
||||
done = assert.async();
|
||||
|
||||
piped.progress(function( result ) {
|
||||
return jQuery.Deferred().resolve().then(function() {
|
||||
piped.progress( function( result ) {
|
||||
return jQuery.Deferred().resolve().then( function() {
|
||||
return result;
|
||||
}).then(function( result ) {
|
||||
} ).then( function( result ) {
|
||||
value3 = result;
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
defer.progress(function( a, b ) {
|
||||
defer.progress( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.notify( 2, 3 );
|
||||
|
||||
piped.then( null, null, function( result ) {
|
||||
return jQuery.Deferred().resolve().then(function() {
|
||||
return jQuery.Deferred().resolve().then( function() {
|
||||
return result;
|
||||
}).then(function() {
|
||||
} ).then( function() {
|
||||
assert.strictEqual( value1, 2, "first progress value ok" );
|
||||
assert.strictEqual( value2, 3, "second progress value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function( assert ) {
|
||||
|
||||
@@ -379,30 +378,30 @@ QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function(
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.pipe( null, null, function( a, b ) {
|
||||
return jQuery.Deferred(function( defer ) {
|
||||
return jQuery.Deferred( function( defer ) {
|
||||
defer.resolve( a * b );
|
||||
});
|
||||
}),
|
||||
} );
|
||||
} ),
|
||||
done = assert.async();
|
||||
|
||||
piped.done(function( result ) {
|
||||
piped.done( function( result ) {
|
||||
value3 = result;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.progress(function( a, b ) {
|
||||
defer.progress( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.notify( 2, 3 );
|
||||
|
||||
piped.done(function() {
|
||||
piped.done( function() {
|
||||
assert.strictEqual( value1, 2, "first progress value ok" );
|
||||
assert.strictEqual( value2, 3, "second progress value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
done();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - context", function( assert ) {
|
||||
|
||||
@@ -412,48 +411,48 @@ QUnit.test( "jQuery.Deferred.then - context", function( assert ) {
|
||||
context = {},
|
||||
done = jQuery.map( new Array( 4 ), function() { return assert.async(); } );
|
||||
|
||||
jQuery.Deferred().resolveWith( context, [ 2 ] ).then(function( value ) {
|
||||
jQuery.Deferred().resolveWith( context, [ 2 ] ).then( function( value ) {
|
||||
return value * 3;
|
||||
}).done(function( value ) {
|
||||
} ).done( function( value ) {
|
||||
assert.notStrictEqual( this, context, "custom context not propagated through .then" );
|
||||
assert.strictEqual( value, 6, "proper value received" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.Deferred().resolve().then(function() {
|
||||
jQuery.Deferred().resolve().then( function() {
|
||||
return jQuery.Deferred().resolveWith( context );
|
||||
}).done(function() {
|
||||
} ).done( function() {
|
||||
assert.strictEqual( this, context,
|
||||
"custom context of returned deferred correctly propagated" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
defer = jQuery.Deferred();
|
||||
piped = defer.then(function( value ) {
|
||||
piped = defer.then( function( value ) {
|
||||
return value * 3;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.resolve( 2 );
|
||||
|
||||
piped.done(function( value ) {
|
||||
piped.done( function( value ) {
|
||||
assert.strictEqual( this, piped,
|
||||
"default context gets updated to latest promise in the chain" );
|
||||
assert.strictEqual( value, 6, "proper value received" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
defer2 = jQuery.Deferred();
|
||||
piped2 = defer2.then();
|
||||
|
||||
defer2.resolve( 2 );
|
||||
|
||||
piped2.done(function( value ) {
|
||||
piped2.done( function( value ) {
|
||||
assert.strictEqual( this, piped2,
|
||||
"default context updated to latest promise in the chain (without passing function)" );
|
||||
assert.strictEqual( value, 2, "proper value received (without passing function)" );
|
||||
done.pop().call();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) {
|
||||
|
||||
@@ -463,66 +462,66 @@ QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) {
|
||||
context = {},
|
||||
done = jQuery.map( new Array( 4 ), function() { return assert.async(); } );
|
||||
|
||||
jQuery.Deferred().resolveWith( context, [ 2 ] ).pipe(function( value ) {
|
||||
jQuery.Deferred().resolveWith( context, [ 2 ] ).pipe( function( value ) {
|
||||
return value * 3;
|
||||
}).done(function( value ) {
|
||||
} ).done( function( value ) {
|
||||
assert.strictEqual( this, context, "[PIPE ONLY] custom context correctly propagated" );
|
||||
assert.strictEqual( value, 6, "proper value received" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.Deferred().resolve().pipe(function() {
|
||||
return jQuery.Deferred().resolveWith(context);
|
||||
}).done(function() {
|
||||
jQuery.Deferred().resolve().pipe( function() {
|
||||
return jQuery.Deferred().resolveWith( context );
|
||||
} ).done( function() {
|
||||
assert.strictEqual( this, context,
|
||||
"custom context of returned deferred correctly propagated" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
defer = jQuery.Deferred();
|
||||
piped = defer.pipe(function( value ) {
|
||||
piped = defer.pipe( function( value ) {
|
||||
return value * 3;
|
||||
});
|
||||
} );
|
||||
|
||||
defer.resolve( 2 );
|
||||
|
||||
piped.done(function( value ) {
|
||||
piped.done( function( value ) {
|
||||
assert.strictEqual( this, piped,
|
||||
"default context gets updated to latest promise in the chain" );
|
||||
assert.strictEqual( value, 6, "proper value received" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
defer2 = jQuery.Deferred();
|
||||
piped2 = defer2.pipe();
|
||||
|
||||
defer2.resolve( 2 );
|
||||
|
||||
piped2.done(function( value ) {
|
||||
piped2.done( function( value ) {
|
||||
assert.strictEqual( this, piped2,
|
||||
"default context updated to latest promise in the chain (without passing function)" );
|
||||
assert.strictEqual( value, 2, "proper value received (without passing function)" );
|
||||
done.pop().call();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.asyncTest( "jQuery.Deferred.then - spec compatibility", function( assert ) {
|
||||
|
||||
assert.expect( 1 );
|
||||
|
||||
var defer = jQuery.Deferred().done(function() {
|
||||
var defer = jQuery.Deferred().done( function() {
|
||||
setTimeout( start );
|
||||
throw new Error();
|
||||
});
|
||||
} );
|
||||
|
||||
defer.then(function() {
|
||||
defer.then( function() {
|
||||
assert.ok( true, "errors in .done callbacks don't stop .then handlers" );
|
||||
});
|
||||
} );
|
||||
|
||||
try {
|
||||
defer.resolve();
|
||||
} catch ( _ ) {}
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) {
|
||||
|
||||
@@ -534,46 +533,46 @@ QUnit.test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) {
|
||||
|
||||
thenable.unwrapped = false;
|
||||
|
||||
jQuery.Deferred().resolve( 1, 2 ).then(function() {
|
||||
jQuery.Deferred().resolve( 1, 2 ).then( function() {
|
||||
assert.deepEqual( [].slice.call( arguments ), [ 1, 2 ],
|
||||
".then fulfillment callbacks receive all resolution values" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
jQuery.Deferred().reject( 1, 2 ).then( null, function() {
|
||||
assert.deepEqual( [].slice.call( arguments ), [ 1, 2 ],
|
||||
".then rejection callbacks receive all rejection values" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
jQuery.Deferred().notify( 1, 2 ).then( null, null, function() {
|
||||
assert.deepEqual( [].slice.call( arguments ), [ 1, 2 ],
|
||||
".then progress callbacks receive all progress values" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.Deferred().resolveWith( context ).then(function() {
|
||||
jQuery.Deferred().resolveWith( context ).then( function() {
|
||||
assert.deepEqual( this, context, ".then fulfillment callbacks receive context" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
jQuery.Deferred().rejectWith( context ).then( null, function() {
|
||||
assert.deepEqual( this, context, ".then rejection callbacks receive context" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
jQuery.Deferred().notifyWith( context ).then( null, null, function() {
|
||||
assert.deepEqual( this, context, ".then progress callbacks receive context" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.Deferred().resolve( thenable ).done(function( value ) {
|
||||
jQuery.Deferred().resolve( thenable ).done( function( value ) {
|
||||
assert.strictEqual( value, thenable, ".done doesn't unwrap thenables" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.Deferred().notify( thenable ).then().then( null, null, function( value ) {
|
||||
assert.strictEqual( value, "thenable fulfillment",
|
||||
".then implicit progress callbacks unwrap thenables" );
|
||||
done.pop().call();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - progress and thenables", function( assert ) {
|
||||
|
||||
@@ -590,16 +589,16 @@ QUnit.test( "jQuery.Deferred.then - progress and thenables", function( assert )
|
||||
|
||||
trigger.then( null, null, function() {
|
||||
var notifier = jQuery.Deferred().notify( "foo" );
|
||||
setTimeout(function() {
|
||||
setTimeout( function() {
|
||||
notifier.notify( "bar" ).resolve( "baz" );
|
||||
});
|
||||
} );
|
||||
return notifier;
|
||||
}).then( failer( "fulfill" ), failer( "reject" ), function( v ) {
|
||||
} ).then( failer( "fulfill" ), failer( "reject" ), function( v ) {
|
||||
assert.strictEqual( v, expectedProgress.shift(), "expected progress value" );
|
||||
done.pop().call();
|
||||
});
|
||||
} );
|
||||
trigger.notify();
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred - notify and resolve", function( assert ) {
|
||||
|
||||
@@ -643,18 +642,19 @@ QUnit.test( "jQuery.Deferred - notify and resolve", function( assert ) {
|
||||
notifiedResolved.then( null, null, function() {
|
||||
return jQuery.Deferred().notify( "baz" ).resolve( "quux" );
|
||||
} ).progress( function( v ) {
|
||||
|
||||
// Progress from the surrogate deferred is ignored
|
||||
assert.strictEqual( v, "quux", "deferred replaced then'd progress value" );
|
||||
done.pop().call();
|
||||
} );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.when", function( assert ) {
|
||||
|
||||
assert.expect( 37 );
|
||||
|
||||
// Some other objects
|
||||
jQuery.each({
|
||||
jQuery.each( {
|
||||
"an empty string": "",
|
||||
"a non-empty string": "some string",
|
||||
"zero": 0,
|
||||
@@ -669,21 +669,21 @@ QUnit.test( "jQuery.when", function( assert ) {
|
||||
}, function( message, value ) {
|
||||
assert.ok(
|
||||
jQuery.isFunction(
|
||||
jQuery.when( value ).done(function( resolveValue ) {
|
||||
jQuery.when( value ).done( function( resolveValue ) {
|
||||
assert.strictEqual( this, window, "Context is the global object with " + message );
|
||||
assert.strictEqual( resolveValue, value, "Test the promise was resolved with " + message );
|
||||
}).promise
|
||||
} ).promise
|
||||
),
|
||||
"Test " + message + " triggers the creation of a new Promise"
|
||||
);
|
||||
});
|
||||
} );
|
||||
|
||||
assert.ok(
|
||||
jQuery.isFunction(
|
||||
jQuery.when().done(function( resolveValue ) {
|
||||
jQuery.when().done( function( resolveValue ) {
|
||||
assert.strictEqual( this, window, "Test the promise was resolved with window as its context" );
|
||||
assert.strictEqual( resolveValue, undefined, "Test the promise was resolved with no parameter" );
|
||||
}).promise
|
||||
} ).promise
|
||||
),
|
||||
"Test calling when with no parameter triggers the creation of a new Promise"
|
||||
);
|
||||
@@ -691,23 +691,23 @@ QUnit.test( "jQuery.when", function( assert ) {
|
||||
var cache,
|
||||
context = {};
|
||||
|
||||
jQuery.when( jQuery.Deferred().resolveWith( context ) ).done(function() {
|
||||
jQuery.when( jQuery.Deferred().resolveWith( context ) ).done( function() {
|
||||
assert.strictEqual( this, context, "when( promise ) propagates context" );
|
||||
});
|
||||
} );
|
||||
|
||||
jQuery.each([ 1, 2, 3 ], function( k, i ) {
|
||||
jQuery.each( [ 1, 2, 3 ], function( k, i ) {
|
||||
|
||||
jQuery.when( cache || jQuery.Deferred(function() {
|
||||
jQuery.when( cache || jQuery.Deferred( function() {
|
||||
this.resolve( i );
|
||||
})
|
||||
).done(function( value ) {
|
||||
} )
|
||||
).done( function( value ) {
|
||||
|
||||
assert.strictEqual( value, 1, "Function executed" + ( i > 1 ? " only once" : "" ) );
|
||||
cache = value;
|
||||
});
|
||||
} );
|
||||
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.when - joined", function( assert ) {
|
||||
|
||||
@@ -762,7 +762,7 @@ QUnit.test( "jQuery.when - joined", function( assert ) {
|
||||
context2 = defer2 && jQuery.isFunction( defer2.promise ) ? defer2.promise() :
|
||||
( defer2.then ? window : undefined );
|
||||
|
||||
jQuery.when( defer1, defer2 ).done(function( a, b ) {
|
||||
jQuery.when( defer1, defer2 ).done( function( a, b ) {
|
||||
if ( shouldResolve ) {
|
||||
assert.deepEqual( [ a, b ], expected, code + " => resolve" );
|
||||
assert.strictEqual( this[ 0 ], context1, code + " => first context OK" );
|
||||
@@ -770,22 +770,22 @@ QUnit.test( "jQuery.when - joined", function( assert ) {
|
||||
} else {
|
||||
assert.ok( false, code + " => resolve" );
|
||||
}
|
||||
}).fail(function( a, b ) {
|
||||
} ).fail( function( a, b ) {
|
||||
if ( shouldError ) {
|
||||
assert.deepEqual( [ a, b ], expected, code + " => reject" );
|
||||
} else {
|
||||
assert.ok( false, code + " => reject" );
|
||||
}
|
||||
}).progress(function( a, b ) {
|
||||
} ).progress( function( a, b ) {
|
||||
assert.deepEqual( [ a, b ], expectedNotify, code + " => progress" );
|
||||
assert.strictEqual( this[ 0 ], expectedNotify[ 0 ] ? context1 : undefined, code + " => first context OK" );
|
||||
assert.strictEqual( this[ 1 ], expectedNotify[ 1 ] ? context2 : undefined, code + " => second context OK" );
|
||||
}).always( restart );
|
||||
});
|
||||
});
|
||||
} ).always( restart );
|
||||
} );
|
||||
} );
|
||||
deferreds.eventuallyFulfilled.resolve( 1 );
|
||||
deferreds.eventuallyRejected.reject( 0 );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.when - resolved", function( assert ) {
|
||||
|
||||
@@ -795,18 +795,18 @@ QUnit.test( "jQuery.when - resolved", function( assert ) {
|
||||
b = jQuery.Deferred().notify( 2 ).resolve( 5 ),
|
||||
c = jQuery.Deferred().notify( 3 ).resolve( 6 );
|
||||
|
||||
jQuery.when( a, b, c ).progress(function( a, b, c ) {
|
||||
jQuery.when( a, b, c ).progress( function( a, b, c ) {
|
||||
assert.strictEqual( a, 1, "first notify value ok" );
|
||||
assert.strictEqual( b, 2, "second notify value ok" );
|
||||
assert.strictEqual( c, 3, "third notify value ok" );
|
||||
}).done(function( a, b, c ) {
|
||||
} ).done( function( a, b, c ) {
|
||||
assert.strictEqual( a, 4, "first resolve value ok" );
|
||||
assert.strictEqual( b, 5, "second resolve value ok" );
|
||||
assert.strictEqual( c, 6, "third resolve value ok" );
|
||||
}).fail(function() {
|
||||
} ).fail( function() {
|
||||
assert.ok( false, "Error on resolve" );
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.when - filtering", function( assert ) {
|
||||
|
||||
@@ -821,12 +821,12 @@ QUnit.test( "jQuery.when - filtering", function( assert ) {
|
||||
jQuery.when(
|
||||
jQuery.Deferred().resolve( 3 ).then( increment ),
|
||||
jQuery.Deferred().reject( 5 ).then( null, increment )
|
||||
).done(function( four, six ) {
|
||||
).done( function( four, six ) {
|
||||
assert.strictEqual( four, 4, "resolved value incremented" );
|
||||
assert.strictEqual( six, 6, "rejected value incremented" );
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.when - exceptions", function( assert ) {
|
||||
|
||||
@@ -838,14 +838,14 @@ QUnit.test( "jQuery.when - exceptions", function( assert ) {
|
||||
|
||||
QUnit.stop();
|
||||
|
||||
jQuery.Deferred().resolve().then( woops ).fail(function( doneException ) {
|
||||
jQuery.Deferred().resolve().then( woops ).fail( function( doneException ) {
|
||||
assert.strictEqual( doneException, "exception thrown", "throwing in done handler" );
|
||||
jQuery.Deferred().reject().then( null, woops ).fail(function( failException ) {
|
||||
jQuery.Deferred().reject().then( null, woops ).fail( function( failException ) {
|
||||
assert.strictEqual( failException, "exception thrown", "throwing in fail handler" );
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.when - chaining", function( assert ) {
|
||||
|
||||
@@ -868,13 +868,13 @@ QUnit.test( "jQuery.when - chaining", function( assert ) {
|
||||
jQuery.Deferred().reject( 5 ).then( null, chain ),
|
||||
jQuery.Deferred().resolve( 3 ).then( chainStandard ),
|
||||
jQuery.Deferred().reject( 5 ).then( null, chainStandard )
|
||||
).done(function( v1, v2, s1, s2 ) {
|
||||
).done( function( v1, v2, s1, s2 ) {
|
||||
assert.strictEqual( v1, "other deferred", "chaining in done handler" );
|
||||
assert.strictEqual( v2, "other deferred", "chaining in fail handler" );
|
||||
assert.strictEqual( s1, "std deferred", "chaining thenable in done handler" );
|
||||
assert.strictEqual( s2, "std deferred", "chaining thenable in fail handler" );
|
||||
QUnit.start();
|
||||
});
|
||||
} );
|
||||
|
||||
defer.resolve( "other deferred" );
|
||||
});
|
||||
} );
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
QUnit.module("deprecated", { teardown: moduleTeardown });
|
||||
QUnit.module( "deprecated", { teardown: moduleTeardown } );
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
(function() {
|
||||
( function() {
|
||||
|
||||
if ( !jQuery.fn.width ) {
|
||||
return;
|
||||
}
|
||||
|
||||
QUnit.module("dimensions", { teardown: moduleTeardown });
|
||||
QUnit.module( "dimensions", { teardown: moduleTeardown } );
|
||||
|
||||
function pass( val ) {
|
||||
return val;
|
||||
@@ -29,111 +29,111 @@ function fn( val ) {
|
||||
*/
|
||||
|
||||
function testWidth( val, assert ) {
|
||||
assert.expect(9);
|
||||
assert.expect( 9 );
|
||||
var $div, blah;
|
||||
|
||||
$div = jQuery("#nothiddendiv");
|
||||
$div.width( val(30) );
|
||||
assert.equal($div.width(), 30, "Test set to 30 correctly");
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.width( val( 30 ) );
|
||||
assert.equal( $div.width(), 30, "Test set to 30 correctly" );
|
||||
$div.hide();
|
||||
assert.equal($div.width(), 30, "Test hidden div");
|
||||
assert.equal( $div.width(), 30, "Test hidden div" );
|
||||
$div.show();
|
||||
$div.width( val(-1) ); // handle negative numbers by setting to 0 #11604
|
||||
assert.equal($div.width(), 0, "Test negative width normalized to 0");
|
||||
$div.css("padding", "20px");
|
||||
assert.equal($div.width(), 0, "Test padding specified with pixels");
|
||||
$div.css("border", "2px solid #fff");
|
||||
assert.equal($div.width(), 0, "Test border specified with pixels");
|
||||
$div.width( val( -1 ) ); // handle negative numbers by setting to 0 #11604
|
||||
assert.equal( $div.width(), 0, "Test negative width normalized to 0" );
|
||||
$div.css( "padding", "20px" );
|
||||
assert.equal( $div.width(), 0, "Test padding specified with pixels" );
|
||||
$div.css( "border", "2px solid #fff" );
|
||||
assert.equal( $div.width(), 0, "Test border specified with pixels" );
|
||||
|
||||
$div.css({ "display": "", "border": "", "padding": "" });
|
||||
$div.css( { "display": "", "border": "", "padding": "" } );
|
||||
|
||||
jQuery("#nothiddendivchild").css({ "width": 20, "padding": "3px", "border": "2px solid #fff" });
|
||||
assert.equal(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");
|
||||
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "width": "" });
|
||||
jQuery( "#nothiddendivchild" ).css( { "width": 20, "padding": "3px", "border": "2px solid #fff" } );
|
||||
assert.equal( jQuery( "#nothiddendivchild" ).width(), 20, "Test child width with border and padding" );
|
||||
jQuery( "#nothiddendiv, #nothiddendivchild" ).css( { "border": "", "padding": "", "width": "" } );
|
||||
|
||||
blah = jQuery("blah");
|
||||
assert.equal( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
|
||||
assert.equal( blah.width(), null, "Make sure 'null' is returned on an empty set");
|
||||
blah = jQuery( "blah" );
|
||||
assert.equal( blah.width( val( 10 ) ), blah, "Make sure that setting a width on an empty set returns the set." );
|
||||
assert.equal( blah.width(), null, "Make sure 'null' is returned on an empty set" );
|
||||
|
||||
assert.equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
|
||||
assert.equal( jQuery( window ).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
|
||||
|
||||
QUnit.expectJqData( this, $div[0], "olddisplay" );
|
||||
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
|
||||
}
|
||||
|
||||
QUnit.test("width()", function( assert ) {
|
||||
QUnit.test( "width()", function( assert ) {
|
||||
testWidth( pass, assert );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("width(Function)", function( assert ) {
|
||||
QUnit.test( "width(Function)", function( assert ) {
|
||||
testWidth( fn, assert );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("width(Function(args))", function( assert ) {
|
||||
QUnit.test( "width(Function(args))", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var $div = jQuery("#nothiddendiv");
|
||||
$div.width( 30 ).width(function(i, width) {
|
||||
var $div = jQuery( "#nothiddendiv" );
|
||||
$div.width( 30 ).width( function( i, width ) {
|
||||
assert.equal( width, 30, "Make sure previous value is correct." );
|
||||
return width + 1;
|
||||
});
|
||||
} );
|
||||
|
||||
assert.equal( $div.width(), 31, "Make sure value was modified correctly." );
|
||||
});
|
||||
} );
|
||||
|
||||
function testHeight( val, assert ) {
|
||||
assert.expect(9);
|
||||
assert.expect( 9 );
|
||||
|
||||
var $div, blah;
|
||||
|
||||
$div = jQuery("#nothiddendiv");
|
||||
$div.height( val(30) );
|
||||
assert.equal($div.height(), 30, "Test set to 30 correctly");
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.height( val( 30 ) );
|
||||
assert.equal( $div.height(), 30, "Test set to 30 correctly" );
|
||||
$div.hide();
|
||||
assert.equal($div.height(), 30, "Test hidden div");
|
||||
assert.equal( $div.height(), 30, "Test hidden div" );
|
||||
$div.show();
|
||||
$div.height( val(-1) ); // handle negative numbers by setting to 0 #11604
|
||||
assert.equal($div.height(), 0, "Test negative height normalized to 0");
|
||||
$div.css("padding", "20px");
|
||||
assert.equal($div.height(), 0, "Test padding specified with pixels");
|
||||
$div.css("border", "2px solid #fff");
|
||||
assert.equal($div.height(), 0, "Test border specified with pixels");
|
||||
$div.height( val( -1 ) ); // handle negative numbers by setting to 0 #11604
|
||||
assert.equal( $div.height(), 0, "Test negative height normalized to 0" );
|
||||
$div.css( "padding", "20px" );
|
||||
assert.equal( $div.height(), 0, "Test padding specified with pixels" );
|
||||
$div.css( "border", "2px solid #fff" );
|
||||
assert.equal( $div.height(), 0, "Test border specified with pixels" );
|
||||
|
||||
$div.css({ "display": "", "border": "", "padding": "", "height": "1px" });
|
||||
$div.css( { "display": "", "border": "", "padding": "", "height": "1px" } );
|
||||
|
||||
jQuery("#nothiddendivchild").css({ "height": 20, "padding": "3px", "border": "2px solid #fff" });
|
||||
assert.equal(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
|
||||
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "height": "" });
|
||||
jQuery( "#nothiddendivchild" ).css( { "height": 20, "padding": "3px", "border": "2px solid #fff" } );
|
||||
assert.equal( jQuery( "#nothiddendivchild" ).height(), 20, "Test child height with border and padding" );
|
||||
jQuery( "#nothiddendiv, #nothiddendivchild" ).css( { "border": "", "padding": "", "height": "" } );
|
||||
|
||||
blah = jQuery("blah");
|
||||
assert.equal( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
|
||||
assert.equal( blah.height(), null, "Make sure 'null' is returned on an empty set");
|
||||
blah = jQuery( "blah" );
|
||||
assert.equal( blah.height( val( 10 ) ), blah, "Make sure that setting a height on an empty set returns the set." );
|
||||
assert.equal( blah.height(), null, "Make sure 'null' is returned on an empty set" );
|
||||
|
||||
assert.equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
|
||||
assert.equal( jQuery( window ).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
|
||||
|
||||
QUnit.expectJqData( this, $div[0], "olddisplay" );
|
||||
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
|
||||
}
|
||||
|
||||
QUnit.test("height()", function( assert ) {
|
||||
QUnit.test( "height()", function( assert ) {
|
||||
testHeight( pass, assert );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("height(Function)", function( assert ) {
|
||||
QUnit.test( "height(Function)", function( assert ) {
|
||||
testHeight( fn, assert );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("height(Function(args))", function( assert ) {
|
||||
QUnit.test( "height(Function(args))", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var $div = jQuery("#nothiddendiv");
|
||||
$div.height( 30 ).height(function(i, height) {
|
||||
var $div = jQuery( "#nothiddendiv" );
|
||||
$div.height( 30 ).height( function( i, height ) {
|
||||
assert.equal( height, 30, "Make sure previous value is correct." );
|
||||
return height + 1;
|
||||
});
|
||||
} );
|
||||
|
||||
assert.equal( $div.height(), 31, "Make sure value was modified correctly." );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("innerWidth()", function( assert ) {
|
||||
QUnit.test( "innerWidth()", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var $div, div,
|
||||
@@ -144,11 +144,11 @@ QUnit.test("innerWidth()", function( assert ) {
|
||||
assert.equal( jQuery( document ).innerWidth(), $doc.width(), "Test on document" );
|
||||
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.css({
|
||||
$div.css( {
|
||||
"margin": 10,
|
||||
"border": "2px solid #fff",
|
||||
"width": 30
|
||||
});
|
||||
} );
|
||||
|
||||
assert.equal( $div.innerWidth(), 30, "Test with margin and border" );
|
||||
$div.css( "padding", "20px" );
|
||||
@@ -157,7 +157,7 @@ QUnit.test("innerWidth()", function( assert ) {
|
||||
assert.equal( $div.innerWidth(), 70, "Test hidden div" );
|
||||
|
||||
// reset styles
|
||||
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
$div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } );
|
||||
|
||||
div = jQuery( "<div>" );
|
||||
|
||||
@@ -166,9 +166,9 @@ QUnit.test("innerWidth()", function( assert ) {
|
||||
|
||||
div.remove();
|
||||
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("innerHeight()", function( assert ) {
|
||||
QUnit.test( "innerHeight()", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var $div, div,
|
||||
@@ -179,11 +179,11 @@ QUnit.test("innerHeight()", function( assert ) {
|
||||
assert.equal( jQuery( document ).innerHeight(), $doc.height(), "Test on document" );
|
||||
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.css({
|
||||
$div.css( {
|
||||
"margin": 10,
|
||||
"border": "2px solid #fff",
|
||||
"height": 30
|
||||
});
|
||||
} );
|
||||
|
||||
assert.equal( $div.innerHeight(), 30, "Test with margin and border" );
|
||||
$div.css( "padding", "20px" );
|
||||
@@ -192,7 +192,7 @@ QUnit.test("innerHeight()", function( assert ) {
|
||||
assert.equal( $div.innerHeight(), 70, "Test hidden div" );
|
||||
|
||||
// reset styles
|
||||
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
$div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } );
|
||||
|
||||
div = jQuery( "<div>" );
|
||||
|
||||
@@ -201,9 +201,9 @@ QUnit.test("innerHeight()", function( assert ) {
|
||||
|
||||
div.remove();
|
||||
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("outerWidth()", function( assert ) {
|
||||
QUnit.test( "outerWidth()", function( assert ) {
|
||||
assert.expect( 11 );
|
||||
|
||||
var $div, div,
|
||||
@@ -231,7 +231,7 @@ QUnit.test("outerWidth()", function( assert ) {
|
||||
assert.equal( $div.outerWidth( true ), 94, "Test hidden div with padding, border and margin with margin option" );
|
||||
|
||||
// reset styles
|
||||
$div.css({ "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
$div.css( { "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" } );
|
||||
|
||||
div = jQuery( "<div>" );
|
||||
|
||||
@@ -240,23 +240,23 @@ QUnit.test("outerWidth()", function( assert ) {
|
||||
|
||||
div.remove();
|
||||
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function( assert ) {
|
||||
assert.expect(16);
|
||||
QUnit.test( "child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function( assert ) {
|
||||
assert.expect( 16 );
|
||||
|
||||
// setup html
|
||||
var $divNormal = jQuery("<div>").css({ "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
|
||||
var $divNormal = jQuery( "<div>" ).css( { "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" } ),
|
||||
$divChild = $divNormal.clone(),
|
||||
$divUnconnected = $divNormal.clone(),
|
||||
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
|
||||
$divNormal.appendTo("body");
|
||||
$divHiddenParent = jQuery( "<div>" ).css( "display", "none" ).append( $divChild ).appendTo( "body" );
|
||||
$divNormal.appendTo( "body" );
|
||||
|
||||
// tests that child div of a hidden div works the same as a normal div
|
||||
assert.equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" );
|
||||
assert.equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" );
|
||||
assert.equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" );
|
||||
assert.equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" );
|
||||
assert.equal( $divChild.outerWidth( true ), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" );
|
||||
|
||||
// Support: IE 10-11, Edge
|
||||
// Child height is not always decimal
|
||||
@@ -269,7 +269,7 @@ QUnit.test("child of a hidden elem (or unconnected node) has accurate inner/oute
|
||||
assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" );
|
||||
assert.equal( $divUnconnected.outerWidth( true ), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" );
|
||||
|
||||
// Support: IE 10-11, Edge
|
||||
// Child height is not always decimal
|
||||
@@ -281,9 +281,9 @@ QUnit.test("child of a hidden elem (or unconnected node) has accurate inner/oute
|
||||
// teardown html
|
||||
$divHiddenParent.remove();
|
||||
$divNormal.remove();
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("getting dimensions shouldn't modify runtimeStyle see #9233", function( assert ) {
|
||||
QUnit.test( "getting dimensions shouldn't modify runtimeStyle see #9233", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
|
||||
@@ -304,36 +304,36 @@ QUnit.test("getting dimensions shouldn't modify runtimeStyle see #9233", functio
|
||||
}
|
||||
|
||||
$div.remove();
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "table dimensions", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var table = jQuery("<table><colgroup><col/><col/></colgroup><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>").appendTo("#qunit-fixture"),
|
||||
tdElem = table.find("td").first(),
|
||||
colElem = table.find("col").first().width( 300 );
|
||||
var table = jQuery( "<table><colgroup><col/><col/></colgroup><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>" ).appendTo( "#qunit-fixture" ),
|
||||
tdElem = table.find( "td" ).first(),
|
||||
colElem = table.find( "col" ).first().width( 300 );
|
||||
|
||||
table.find("td").css({ "margin": 0, "padding": 0 });
|
||||
table.find( "td" ).css( { "margin": 0, "padding": 0 } );
|
||||
|
||||
assert.equal( tdElem.width(), tdElem.width(), "width() doesn't alter dimension values of empty cells, see #11293" );
|
||||
assert.equal( colElem.width(), 300, "col elements have width(), see #12243" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function( assert ) {
|
||||
assert.expect(16);
|
||||
QUnit.test( "box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function( assert ) {
|
||||
assert.expect( 16 );
|
||||
|
||||
// setup html
|
||||
var $divNormal = jQuery("<div>").css({ "boxSizing": "border-box", "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
|
||||
var $divNormal = jQuery( "<div>" ).css( { "boxSizing": "border-box", "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" } ),
|
||||
$divChild = $divNormal.clone(),
|
||||
$divUnconnected = $divNormal.clone(),
|
||||
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
|
||||
$divNormal.appendTo("body");
|
||||
$divHiddenParent = jQuery( "<div>" ).css( "display", "none" ).append( $divChild ).appendTo( "body" );
|
||||
$divNormal.appendTo( "body" );
|
||||
|
||||
// tests that child div of a hidden div works the same as a normal div
|
||||
assert.equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #10413" );
|
||||
assert.equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #10413" );
|
||||
assert.equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #10413" );
|
||||
assert.equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" );
|
||||
assert.equal( $divChild.outerWidth( true ), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" );
|
||||
|
||||
// Support: IE 10-11, Edge
|
||||
// Child height is not always decimal
|
||||
@@ -346,7 +346,7 @@ QUnit.test("box-sizing:border-box child of a hidden elem (or unconnected node) h
|
||||
assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.outerWidth( true ), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" );
|
||||
|
||||
// Support: IE 10-11, Edge
|
||||
// Child height is not always decimal
|
||||
@@ -358,9 +358,9 @@ QUnit.test("box-sizing:border-box child of a hidden elem (or unconnected node) h
|
||||
// teardown html
|
||||
$divHiddenParent.remove();
|
||||
$divNormal.remove();
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("outerHeight()", function( assert ) {
|
||||
QUnit.test( "outerHeight()", function( assert ) {
|
||||
assert.expect( 11 );
|
||||
|
||||
var $div, div,
|
||||
@@ -387,7 +387,7 @@ QUnit.test("outerHeight()", function( assert ) {
|
||||
assert.equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" );
|
||||
|
||||
// reset styles
|
||||
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
$div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } );
|
||||
|
||||
div = jQuery( "<div>" );
|
||||
|
||||
@@ -396,20 +396,20 @@ QUnit.test("outerHeight()", function( assert ) {
|
||||
|
||||
div.remove();
|
||||
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("passing undefined is a setter #5571", function( assert ) {
|
||||
assert.expect(4);
|
||||
assert.equal(jQuery("#nothiddendiv").height(30).height(undefined).height(), 30, ".height(undefined) is chainable (#5571)");
|
||||
assert.equal(jQuery("#nothiddendiv").height(30).innerHeight(undefined).height(), 30, ".innerHeight(undefined) is chainable (#5571)");
|
||||
assert.equal(jQuery("#nothiddendiv").height(30).outerHeight(undefined).height(), 30, ".outerHeight(undefined) is chainable (#5571)");
|
||||
assert.equal(jQuery("#nothiddendiv").width(30).width(undefined).width(), 30, ".width(undefined) is chainable (#5571)");
|
||||
});
|
||||
QUnit.test( "passing undefined is a setter #5571", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
assert.equal( jQuery( "#nothiddendiv" ).height( 30 ).height( undefined ).height(), 30, ".height(undefined) is chainable (#5571)" );
|
||||
assert.equal( jQuery( "#nothiddendiv" ).height( 30 ).innerHeight( undefined ).height(), 30, ".innerHeight(undefined) is chainable (#5571)" );
|
||||
assert.equal( jQuery( "#nothiddendiv" ).height( 30 ).outerHeight( undefined ).height(), 30, ".outerHeight(undefined) is chainable (#5571)" );
|
||||
assert.equal( jQuery( "#nothiddendiv" ).width( 30 ).width( undefined ).width(), 30, ".width(undefined) is chainable (#5571)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "getters on non elements should return null", function( assert ) {
|
||||
assert.expect( 8 );
|
||||
|
||||
var nonElem = jQuery("notAnElement");
|
||||
var nonElem = jQuery( "notAnElement" );
|
||||
|
||||
assert.strictEqual( nonElem.width(), null, ".width() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.innerWidth(), null, ".innerWidth() is not null (#12283)" );
|
||||
@@ -420,14 +420,14 @@ QUnit.test( "getters on non elements should return null", function( assert ) {
|
||||
assert.strictEqual( nonElem.innerHeight(), null, ".innerHeight() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.outerHeight(), null, ".outerHeight() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.outerHeight( true ), null, ".outerHeight(true) is not null (#12283)" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("setters with and without box-sizing:border-box", function( assert ){
|
||||
assert.expect(20);
|
||||
QUnit.test( "setters with and without box-sizing:border-box", function( assert ) {
|
||||
assert.expect( 20 );
|
||||
|
||||
// Support: Android 2.3 (-webkit-box-sizing).
|
||||
var el_bb = jQuery("<div style='width:114px;height:114px;margin:5px;padding:3px;border:4px solid white;-webkit-box-sizing:border-box;box-sizing:border-box;'>test</div>").appendTo("#qunit-fixture"),
|
||||
el = jQuery("<div style='width:100px;height:100px;margin:5px;padding:3px;border:4px solid white;'>test</div>").appendTo("#qunit-fixture"),
|
||||
var el_bb = jQuery( "<div style='width:114px;height:114px;margin:5px;padding:3px;border:4px solid white;-webkit-box-sizing:border-box;box-sizing:border-box;'>test</div>" ).appendTo( "#qunit-fixture" ),
|
||||
el = jQuery( "<div style='width:100px;height:100px;margin:5px;padding:3px;border:4px solid white;'>test</div>" ).appendTo( "#qunit-fixture" ),
|
||||
expected = 100;
|
||||
|
||||
assert.equal( el_bb.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" );
|
||||
@@ -453,13 +453,13 @@ QUnit.test("setters with and without box-sizing:border-box", function( assert ){
|
||||
assert.equal( el.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" );
|
||||
assert.equal( el.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" );
|
||||
assert.equal( el.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" );
|
||||
});
|
||||
} );
|
||||
|
||||
testIframe(
|
||||
"dimensions/documentLarge",
|
||||
"window vs. large document",
|
||||
function( jQuery, window, document, assert ) {
|
||||
assert.expect(2);
|
||||
assert.expect( 2 );
|
||||
|
||||
assert.ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height" );
|
||||
assert.ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" );
|
||||
@@ -472,15 +472,15 @@ QUnit.test( "allow modification of coordinates argument (gh-1848)", function( as
|
||||
var offsetTop,
|
||||
element = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
element.offset(function( index, coords ) {
|
||||
element.offset( function( index, coords ) {
|
||||
coords.top = 100;
|
||||
|
||||
return coords;
|
||||
});
|
||||
} );
|
||||
|
||||
offsetTop = element.offset().top;
|
||||
assert.ok( Math.abs(offsetTop - 100) < 0.02,
|
||||
"coordinates are modified (got offset.top: " + offsetTop + ")");
|
||||
});
|
||||
assert.ok( Math.abs( offsetTop - 100 ) < 0.02,
|
||||
"coordinates are modified (got offset.top: " + offsetTop + ")" );
|
||||
} );
|
||||
|
||||
})();
|
||||
} )();
|
||||
|
||||
1338
test/unit/effects.js
vendored
1338
test/unit/effects.js
vendored
File diff suppressed because it is too large
Load Diff
1864
test/unit/event.js
1864
test/unit/event.js
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
QUnit.module("exports", { teardown: moduleTeardown });
|
||||
QUnit.module( "exports", { teardown: moduleTeardown } );
|
||||
|
||||
QUnit.test("amdModule", function( assert ) {
|
||||
assert.expect(1);
|
||||
QUnit.test( "amdModule", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
assert.equal( jQuery, amdDefined, "Make sure defined module matches jQuery" );
|
||||
});
|
||||
} );
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,38 +1,39 @@
|
||||
(function() {
|
||||
( function() {
|
||||
|
||||
if ( !jQuery.fn.offset ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var supportsScroll, supportsFixedPosition,
|
||||
forceScroll = jQuery("<div/>").css({ width: 2000, height: 2000 }),
|
||||
forceScroll = jQuery( "<div/>" ).css( { width: 2000, height: 2000 } ),
|
||||
checkSupport = function() {
|
||||
|
||||
// Only run once
|
||||
checkSupport = false;
|
||||
|
||||
var checkFixed = jQuery("<div/>").css({ position: "fixed", top: "20px" }).appendTo("#qunit-fixture");
|
||||
var checkFixed = jQuery( "<div/>" ).css( { position: "fixed", top: "20px" } ).appendTo( "#qunit-fixture" );
|
||||
|
||||
// Must append to body because #qunit-fixture is hidden and elements inside it don't have a scrollTop
|
||||
forceScroll.appendTo("body");
|
||||
forceScroll.appendTo( "body" );
|
||||
window.scrollTo( 200, 200 );
|
||||
supportsScroll = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
forceScroll.detach();
|
||||
|
||||
supportsFixedPosition = checkFixed[0].offsetTop === 20;
|
||||
supportsFixedPosition = checkFixed[ 0 ].offsetTop === 20;
|
||||
checkFixed.remove();
|
||||
};
|
||||
|
||||
QUnit.module("offset", { setup: function(){
|
||||
QUnit.module( "offset", { setup: function() {
|
||||
if ( typeof checkSupport === "function" ) {
|
||||
checkSupport();
|
||||
}
|
||||
|
||||
// Force a scroll value on the main window to ensure incorrect results
|
||||
// if offset is using the scroll offset of the parent window
|
||||
forceScroll.appendTo("body");
|
||||
forceScroll.appendTo( "body" );
|
||||
window.scrollTo( 1, 1 );
|
||||
forceScroll.detach();
|
||||
}, teardown: moduleTeardown });
|
||||
}, teardown: moduleTeardown } );
|
||||
|
||||
/*
|
||||
Closure-compiler will roll static methods off of the jQuery object and so they will
|
||||
@@ -41,13 +42,13 @@ QUnit.module("offset", { setup: function(){
|
||||
the iframe window and the "jQuery" symbol is used to access any static methods.
|
||||
*/
|
||||
|
||||
QUnit.test("empty set", function( assert ) {
|
||||
QUnit.test( "empty set", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
assert.strictEqual( jQuery().offset(), undefined, "offset() returns undefined for empty set (#11962)" );
|
||||
assert.strictEqual( jQuery().position(), undefined, "position() returns undefined for empty set (#11962)" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("disconnected element", function( assert ) {
|
||||
QUnit.test( "disconnected element", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var result = jQuery( document.createElement( "div" ) ).offset();
|
||||
@@ -57,12 +58,12 @@ QUnit.test("disconnected element", function( assert ) {
|
||||
// valid input, but will return zeros for back-compat
|
||||
assert.equal( result.top, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" );
|
||||
assert.equal( result.left, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("hidden (display: none) element", function( assert ) {
|
||||
QUnit.test( "hidden (display: none) element", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var node = jQuery("<div style='display: none' />").appendTo("#qunit-fixture"),
|
||||
var node = jQuery( "<div style='display: none' />" ).appendTo( "#qunit-fixture" ),
|
||||
result = node.offset();
|
||||
|
||||
node.remove();
|
||||
@@ -72,10 +73,10 @@ QUnit.test("hidden (display: none) element", function( assert ) {
|
||||
// valid input, but will return zeros for back-compat
|
||||
assert.equal( result.top, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" );
|
||||
assert.equal( result.left, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" );
|
||||
});
|
||||
} );
|
||||
|
||||
testIframe("offset/absolute", "absolute", function( $, iframe, document, assert ) {
|
||||
assert.expect(4);
|
||||
testIframe( "offset/absolute", "absolute", function( $, iframe, document, assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var doc = iframe.document,
|
||||
tests;
|
||||
@@ -85,23 +86,22 @@ testIframe("offset/absolute", "absolute", function( $, iframe, document, assert
|
||||
{ "id": "#absolute-1", "top": 1, "left": 1 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
assert.equal( jQuery( this["id"], doc ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
assert.equal( jQuery( this["id"], doc ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
assert.equal( jQuery( this[ "id" ], doc ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" );
|
||||
assert.equal( jQuery( this[ "id" ], doc ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||
} );
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ "id": "#absolute-1", "top": 0, "left": 0 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
assert.equal( jQuery( this["id"], doc ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
assert.equal( jQuery( this["id"], doc ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
});
|
||||
});
|
||||
assert.equal( jQuery( this[ "id" ], doc ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" );
|
||||
assert.equal( jQuery( this[ "id" ], doc ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" );
|
||||
} );
|
||||
} );
|
||||
|
||||
testIframe("offset/absolute", "absolute", function( $, window, document, assert ) {
|
||||
assert.expect(178);
|
||||
testIframe( "offset/absolute", "absolute", function( $, window, document, assert ) {
|
||||
assert.expect( 178 );
|
||||
|
||||
var tests, offset;
|
||||
|
||||
@@ -113,10 +113,9 @@ testIframe("offset/absolute", "absolute", function( $, window, document, assert
|
||||
{ "id": "#absolute-2", "top": 20, "left": 20 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||
} );
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
@@ -126,16 +125,15 @@ testIframe("offset/absolute", "absolute", function( $, window, document, assert
|
||||
{ "id": "#absolute-2", "top": 19, "left": 19 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
assert.equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
assert.equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
});
|
||||
assert.equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" );
|
||||
assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" );
|
||||
} );
|
||||
|
||||
// test #5781
|
||||
offset = $( "#positionTest" ).offset({ "top": 10, "left": 10 }).offset();
|
||||
offset = $( "#positionTest" ).offset( { "top": 10, "left": 10 } ).offset();
|
||||
assert.equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." );
|
||||
assert.equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." );
|
||||
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
{ "id": "#absolute-2", "top": 30, "left": 30 },
|
||||
@@ -156,39 +154,39 @@ testIframe("offset/absolute", "absolute", function( $, window, document, assert
|
||||
{ "id": "#absolute-1", "top": 1, "left": 1 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" );
|
||||
|
||||
var top = this["top"], left = this["left"];
|
||||
var top = this[ "top" ], left = this[ "left" ];
|
||||
|
||||
$( this["id"] ).offset(function(i, val){
|
||||
$( this[ "id" ] ).offset( function( i, val ) {
|
||||
assert.equal( val.top, top, "Verify incoming top position." );
|
||||
assert.equal( val.left, left, "Verify incoming top position." );
|
||||
return { "top": top + 1, "left": left + 1 };
|
||||
});
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + " })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + " })" );
|
||||
} );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + " })" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + " })" );
|
||||
|
||||
$( this["id"] )
|
||||
.offset({ "left": this["left"] + 2 })
|
||||
.offset({ "top": this["top"] + 2 });
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 2, "Setting one property at a time." );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 2, "Setting one property at a time." );
|
||||
$( this[ "id" ] )
|
||||
.offset( { "left": this[ "left" ] + 2 } )
|
||||
.offset( { "top": this[ "top" ] + 2 } );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 2, "Setting one property at a time." );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 2, "Setting one property at a time." );
|
||||
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) {
|
||||
$( this ).css( {
|
||||
"top": props.top + 1,
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
});
|
||||
});
|
||||
} );
|
||||
} } );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
|
||||
} );
|
||||
} );
|
||||
|
||||
testIframe("offset/relative", "relative", function( $, window, document, assert ) {
|
||||
assert.expect(60);
|
||||
testIframe( "offset/relative", "relative", function( $, window, document, assert ) {
|
||||
assert.expect( 60 );
|
||||
|
||||
// get offset
|
||||
var tests = [
|
||||
@@ -197,10 +195,9 @@ testIframe("offset/relative", "relative", function( $, window, document, assert
|
||||
{ "id": "#relative-2", "top": 142, "left": 27 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||
} );
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
@@ -209,10 +206,9 @@ testIframe("offset/relative", "relative", function( $, window, document, assert
|
||||
{ "id": "#relative-2", "top": 141, "left": 26 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
assert.equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
assert.equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
});
|
||||
|
||||
assert.equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" );
|
||||
assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" );
|
||||
} );
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
@@ -230,22 +226,22 @@ testIframe("offset/relative", "relative", function( $, window, document, assert
|
||||
{ "id": "#relative-1", "top": 7, "left": 7 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" );
|
||||
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) {
|
||||
$( this ).css( {
|
||||
"top": props.top + 1,
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
});
|
||||
});
|
||||
} );
|
||||
} } );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
|
||||
} );
|
||||
} );
|
||||
|
||||
testIframe("offset/static", "static", function( $, window, document, assert ) {
|
||||
testIframe( "offset/static", "static", function( $, window, document, assert ) {
|
||||
assert.expect( 80 );
|
||||
|
||||
// get offset
|
||||
@@ -256,10 +252,9 @@ testIframe("offset/static", "static", function( $, window, document, assert ) {
|
||||
{ "id": "#static-2", "top": 122, left: 7 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||
} );
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
@@ -269,10 +264,9 @@ testIframe("offset/static", "static", function( $, window, document, assert ) {
|
||||
{ "id": "#static-2", "top": 121, "left": 6 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
assert.equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["top"] + "').position().top" );
|
||||
assert.equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["left"] +"').position().left" );
|
||||
});
|
||||
|
||||
assert.equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "top" ] + "').position().top" );
|
||||
assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "left" ] + "').position().left" );
|
||||
} );
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
@@ -294,23 +288,23 @@ testIframe("offset/static", "static", function( $, window, document, assert ) {
|
||||
{ "id": "#static-1", "top": 7, "left": 7 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" );
|
||||
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) {
|
||||
$( this ).css( {
|
||||
"top": props.top + 1,
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
});
|
||||
});
|
||||
} );
|
||||
} } );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
|
||||
} );
|
||||
} );
|
||||
|
||||
testIframe("offset/fixed", "fixed", function( $, window, document, assert ) {
|
||||
assert.expect(34);
|
||||
testIframe( "offset/fixed", "fixed", function( $, window, document, assert ) {
|
||||
assert.expect( 34 );
|
||||
|
||||
var tests, $noTopLeft;
|
||||
|
||||
@@ -339,18 +333,19 @@ testIframe("offset/fixed", "fixed", function( $, window, document, assert ) {
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
|
||||
} else if ( window.supportsFixedPosition ) {
|
||||
assert.equal( $( this["id"] ).offset().top, this["offsetTop"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
assert.equal( $( this["id"] ).position().top, this["positionTop"], "jQuery('" + this["id"] + "').position().top" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["offsetLeft"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
assert.equal( $( this["id"] ).position().left, this["positionLeft"], "jQuery('" + this["id"] + "').position().left" );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "offsetTop" ], "jQuery('" + this[ "id" ] + "').offset().top" );
|
||||
assert.equal( $( this[ "id" ] ).position().top, this[ "positionTop" ], "jQuery('" + this[ "id" ] + "').position().top" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "offsetLeft" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||
assert.equal( $( this[ "id" ] ).position().left, this[ "positionLeft" ], "jQuery('" + this[ "id" ] + "').position().left" );
|
||||
} else {
|
||||
|
||||
// need to have same number of assertions
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
tests = [
|
||||
{ "id": "#fixed-1", "top": 100, "left": 100 },
|
||||
@@ -363,74 +358,76 @@ testIframe("offset/fixed", "fixed", function( $, window, document, assert ) {
|
||||
|
||||
jQuery.each( tests, function() {
|
||||
if ( window.supportsFixedPosition ) {
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" );
|
||||
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) {
|
||||
$( this ).css( {
|
||||
"top": props.top + 1,
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
} );
|
||||
} } );
|
||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
|
||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
|
||||
} else {
|
||||
|
||||
// need to have same number of assertions
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
// Bug 8316
|
||||
$noTopLeft = $("#fixed-no-top-left");
|
||||
$noTopLeft = $( "#fixed-no-top-left" );
|
||||
if ( window.supportsFixedPosition ) {
|
||||
assert.equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
|
||||
assert.equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
|
||||
} else {
|
||||
|
||||
// need to have same number of assertions
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
testIframe("offset/table", "table", function( $, window, document, assert ) {
|
||||
assert.expect(4);
|
||||
testIframe( "offset/table", "table", function( $, window, document, assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
assert.equal( $("#table-1").offset().top, 6, "jQuery('#table-1').offset().top" );
|
||||
assert.equal( $("#table-1").offset().left, 6, "jQuery('#table-1').offset().left" );
|
||||
assert.equal( $( "#table-1" ).offset().top, 6, "jQuery('#table-1').offset().top" );
|
||||
assert.equal( $( "#table-1" ).offset().left, 6, "jQuery('#table-1').offset().left" );
|
||||
|
||||
assert.equal( $("#th-1").offset().top, 10, "jQuery('#th-1').offset().top" );
|
||||
assert.equal( $("#th-1").offset().left, 10, "jQuery('#th-1').offset().left" );
|
||||
});
|
||||
assert.equal( $( "#th-1" ).offset().top, 10, "jQuery('#th-1').offset().top" );
|
||||
assert.equal( $( "#th-1" ).offset().left, 10, "jQuery('#th-1').offset().left" );
|
||||
} );
|
||||
|
||||
testIframe("offset/scroll", "scroll", function( $, win, doc, assert ) {
|
||||
testIframe( "offset/scroll", "scroll", function( $, win, doc, assert ) {
|
||||
assert.expect( 30 );
|
||||
|
||||
assert.equal( $("#scroll-1").offset().top, 7, "jQuery('#scroll-1').offset().top" );
|
||||
assert.equal( $("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
|
||||
assert.equal( $( "#scroll-1" ).offset().top, 7, "jQuery('#scroll-1').offset().top" );
|
||||
assert.equal( $( "#scroll-1" ).offset().left, 7, "jQuery('#scroll-1').offset().left" );
|
||||
|
||||
assert.equal( $("#scroll-1-1").offset().top, 11, "jQuery('#scroll-1-1').offset().top" );
|
||||
assert.equal( $("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
||||
assert.equal( $( "#scroll-1-1" ).offset().top, 11, "jQuery('#scroll-1-1').offset().top" );
|
||||
assert.equal( $( "#scroll-1-1" ).offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
||||
|
||||
// These tests are solely for master/compat consistency
|
||||
// Retrieving offset on disconnected/hidden elements is not officially
|
||||
// valid input, but will return zeros for back-compat
|
||||
assert.equal( $("#hidden").offset().top, 0, "Hidden elements do not subtract scroll" );
|
||||
assert.equal( $("#hidden").offset().left, 0, "Hidden elements do not subtract scroll" );
|
||||
assert.equal( $( "#hidden" ).offset().top, 0, "Hidden elements do not subtract scroll" );
|
||||
assert.equal( $( "#hidden" ).offset().left, 0, "Hidden elements do not subtract scroll" );
|
||||
|
||||
// scroll offset tests .scrollTop/Left
|
||||
assert.equal( $("#scroll-1").scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
|
||||
assert.equal( $("#scroll-1").scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
|
||||
assert.equal( $( "#scroll-1" ).scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
|
||||
assert.equal( $( "#scroll-1" ).scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
|
||||
|
||||
assert.equal( $("#scroll-1-1").scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
|
||||
assert.equal( $("#scroll-1-1").scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
|
||||
assert.equal( $( "#scroll-1-1" ).scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
|
||||
assert.equal( $( "#scroll-1-1" ).scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
|
||||
|
||||
// scroll method chaining
|
||||
assert.equal( $("#scroll-1").scrollTop(undefined).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" );
|
||||
assert.equal( $("#scroll-1").scrollLeft(undefined).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" );
|
||||
assert.equal( $( "#scroll-1" ).scrollTop( undefined ).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" );
|
||||
assert.equal( $( "#scroll-1" ).scrollLeft( undefined ).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" );
|
||||
|
||||
win.name = "test";
|
||||
|
||||
@@ -441,113 +438,113 @@ testIframe("offset/scroll", "scroll", function( $, win, doc, assert ) {
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
} else {
|
||||
assert.equal( $(win).scrollTop(), 1000, "jQuery(window).scrollTop()" );
|
||||
assert.equal( $(win).scrollLeft(), 1000, "jQuery(window).scrollLeft()" );
|
||||
assert.equal( $( win ).scrollTop(), 1000, "jQuery(window).scrollTop()" );
|
||||
assert.equal( $( win ).scrollLeft(), 1000, "jQuery(window).scrollLeft()" );
|
||||
|
||||
assert.equal( $(win.document).scrollTop(), 1000, "jQuery(document).scrollTop()" );
|
||||
assert.equal( $(win.document).scrollLeft(), 1000, "jQuery(document).scrollLeft()" );
|
||||
assert.equal( $( win.document ).scrollTop(), 1000, "jQuery(document).scrollTop()" );
|
||||
assert.equal( $( win.document ).scrollLeft(), 1000, "jQuery(document).scrollLeft()" );
|
||||
}
|
||||
|
||||
// test jQuery using parent window/document
|
||||
// jQuery reference here is in the iframe
|
||||
window.scrollTo(0,0);
|
||||
assert.equal( $(window).scrollTop(), 0, "jQuery(window).scrollTop() other window" );
|
||||
assert.equal( $(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
|
||||
assert.equal( $(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
|
||||
assert.equal( $(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
|
||||
window.scrollTo( 0, 0 );
|
||||
assert.equal( $( window ).scrollTop(), 0, "jQuery(window).scrollTop() other window" );
|
||||
assert.equal( $( window ).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
|
||||
assert.equal( $( document ).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
|
||||
assert.equal( $( document ).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
|
||||
|
||||
// Tests scrollTop/Left with empty jquery objects
|
||||
assert.notEqual( $().scrollTop(100), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollLeft(100), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollTop(null), null, "jQuery().scrollTop(null) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollLeft(null), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollTop( 100 ), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollLeft( 100 ), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollTop( null ), null, "jQuery().scrollTop(null) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollLeft( null ), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
|
||||
assert.strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
assert.strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
|
||||
// Tests position after parent scrolling (#15239)
|
||||
$("#scroll-1").scrollTop(0);
|
||||
$("#scroll-1").scrollLeft(0);
|
||||
assert.equal( $("#scroll-1-1").position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
|
||||
assert.equal( $("#scroll-1-1").position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
|
||||
$( "#scroll-1" ).scrollTop( 0 );
|
||||
$( "#scroll-1" ).scrollLeft( 0 );
|
||||
assert.equal( $( "#scroll-1-1" ).position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
|
||||
assert.equal( $( "#scroll-1-1" ).position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
|
||||
|
||||
$("#scroll-1").scrollTop(5);
|
||||
$("#scroll-1").scrollLeft(5);
|
||||
assert.equal( $("#scroll-1-1").position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
|
||||
assert.equal( $("#scroll-1-1").position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
|
||||
});
|
||||
$( "#scroll-1" ).scrollTop( 5 );
|
||||
$( "#scroll-1" ).scrollLeft( 5 );
|
||||
assert.equal( $( "#scroll-1-1" ).position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
|
||||
assert.equal( $( "#scroll-1-1" ).position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
|
||||
} );
|
||||
|
||||
testIframe("offset/body", "body", function( $, window, document, assert ) {
|
||||
assert.expect(4);
|
||||
testIframe( "offset/body", "body", function( $, window, document, assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
assert.equal( $("body").offset().top, 1, "jQuery('#body').offset().top" );
|
||||
assert.equal( $("body").offset().left, 1, "jQuery('#body').offset().left" );
|
||||
assert.equal( $("#firstElement").position().left, 5, "$('#firstElement').position().left" );
|
||||
assert.equal( $("#firstElement").position().top, 5, "$('#firstElement').position().top" );
|
||||
});
|
||||
assert.equal( $( "body" ).offset().top, 1, "jQuery('#body').offset().top" );
|
||||
assert.equal( $( "body" ).offset().left, 1, "jQuery('#body').offset().left" );
|
||||
assert.equal( $( "#firstElement" ).position().left, 5, "$('#firstElement').position().left" );
|
||||
assert.equal( $( "#firstElement" ).position().top, 5, "$('#firstElement').position().top" );
|
||||
} );
|
||||
|
||||
QUnit.test("chaining", function( assert ) {
|
||||
assert.expect(3);
|
||||
QUnit.test( "chaining", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
var coords = { "top": 1, "left": 1 };
|
||||
assert.equal( jQuery("#absolute-1").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" );
|
||||
assert.equal( jQuery("#non-existent").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" );
|
||||
assert.equal( jQuery("#absolute-1").offset(undefined).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" );
|
||||
});
|
||||
assert.equal( jQuery( "#absolute-1" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" );
|
||||
assert.equal( jQuery( "#non-existent" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" );
|
||||
assert.equal( jQuery( "#absolute-1" ).offset( undefined ).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" );
|
||||
} );
|
||||
|
||||
QUnit.test("offsetParent", function( assert ){
|
||||
assert.expect(13);
|
||||
QUnit.test( "offsetParent", function( assert ) {
|
||||
assert.expect( 13 );
|
||||
|
||||
var body, header, div, area;
|
||||
|
||||
body = jQuery("body").offsetParent();
|
||||
body = jQuery( "body" ).offsetParent();
|
||||
assert.equal( body.length, 1, "Only one offsetParent found." );
|
||||
assert.equal( body[0], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
assert.equal( body[ 0 ], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
|
||||
header = jQuery("#qunit").offsetParent();
|
||||
header = jQuery( "#qunit" ).offsetParent();
|
||||
assert.equal( header.length, 1, "Only one offsetParent found." );
|
||||
assert.equal( header[0], document.documentElement, "The html element is the offsetParent of #qunit." );
|
||||
assert.equal( header[ 0 ], document.documentElement, "The html element is the offsetParent of #qunit." );
|
||||
|
||||
div = jQuery("#nothiddendivchild").offsetParent();
|
||||
div = jQuery( "#nothiddendivchild" ).offsetParent();
|
||||
assert.equal( div.length, 1, "Only one offsetParent found." );
|
||||
assert.equal( div[0], document.getElementById("qunit-fixture"), "The #qunit-fixture is the offsetParent of #nothiddendivchild." );
|
||||
assert.equal( div[ 0 ], document.getElementById( "qunit-fixture" ), "The #qunit-fixture is the offsetParent of #nothiddendivchild." );
|
||||
|
||||
jQuery("#nothiddendiv").css("position", "relative");
|
||||
jQuery( "#nothiddendiv" ).css( "position", "relative" );
|
||||
|
||||
div = jQuery("#nothiddendivchild").offsetParent();
|
||||
div = jQuery( "#nothiddendivchild" ).offsetParent();
|
||||
assert.equal( div.length, 1, "Only one offsetParent found." );
|
||||
assert.equal( div[0], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
|
||||
assert.equal( div[ 0 ], jQuery( "#nothiddendiv" )[ 0 ], "The div is the offsetParent." );
|
||||
|
||||
div = jQuery("body, #nothiddendivchild").offsetParent();
|
||||
div = jQuery( "body, #nothiddendivchild" ).offsetParent();
|
||||
assert.equal( div.length, 2, "Two offsetParent found." );
|
||||
assert.equal( div[0], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
assert.equal( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
|
||||
assert.equal( div[ 0 ], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
assert.equal( div[ 1 ], jQuery( "#nothiddendiv" )[ 0 ], "The div is the offsetParent." );
|
||||
|
||||
area = jQuery("#imgmap area").offsetParent();
|
||||
assert.equal( area[0], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
area = jQuery( "#imgmap area" ).offsetParent();
|
||||
assert.equal( area[ 0 ], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
|
||||
div = jQuery("<div>").css({ "position": "absolute" }).appendTo("body");
|
||||
assert.equal( div.offsetParent()[0], document.documentElement, "Absolutely positioned div returns html as offset parent, see #12139" );
|
||||
div = jQuery( "<div>" ).css( { "position": "absolute" } ).appendTo( "body" );
|
||||
assert.equal( div.offsetParent()[ 0 ], document.documentElement, "Absolutely positioned div returns html as offset parent, see #12139" );
|
||||
|
||||
div.remove();
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("fractions (see #7730 and #7885)", function( assert ) {
|
||||
assert.expect(2);
|
||||
QUnit.test( "fractions (see #7730 and #7885)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
jQuery("body").append("<div id='fractions'/>");
|
||||
jQuery( "body" ).append( "<div id='fractions'/>" );
|
||||
|
||||
var result,
|
||||
expected = { "top": 1000, "left": 1000 },
|
||||
div = jQuery("#fractions");
|
||||
div = jQuery( "#fractions" );
|
||||
|
||||
div.css({
|
||||
div.css( {
|
||||
"position": "absolute",
|
||||
"left": "1000.7432222px",
|
||||
"top": "1000.532325px",
|
||||
"width": 100,
|
||||
"height": 100
|
||||
});
|
||||
} );
|
||||
|
||||
div.offset(expected);
|
||||
div.offset( expected );
|
||||
|
||||
result = div.offset();
|
||||
|
||||
@@ -555,9 +552,9 @@ QUnit.test("fractions (see #7730 and #7885)", function( assert ) {
|
||||
assert.equal( result.left, expected.left, "Check left" );
|
||||
|
||||
div.remove();
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("iframe scrollTop/Left (see gh-1945)", function( assert ) {
|
||||
QUnit.test( "iframe scrollTop/Left (see gh-1945)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var ifDoc = jQuery( "#iframe" )[ 0 ].contentDocument;
|
||||
@@ -572,6 +569,7 @@ QUnit.test("iframe scrollTop/Left (see gh-1945)", function( assert ) {
|
||||
assert.equal( true, true, "Can't scroll iframes in this environment" );
|
||||
|
||||
} else {
|
||||
|
||||
// Tests scrollTop/Left with iframes
|
||||
jQuery( "#iframe" ).css( "width", "50px" ).css( "height", "50px" );
|
||||
ifDoc.write( "<div style='width: 1000px; height: 1000px;'></div>" );
|
||||
@@ -582,6 +580,6 @@ QUnit.test("iframe scrollTop/Left (see gh-1945)", function( assert ) {
|
||||
assert.equal( jQuery( ifDoc ).scrollTop(), 200, "$($('#iframe')[0].contentDocument).scrollTop()" );
|
||||
assert.equal( jQuery( ifDoc ).scrollLeft(), 500, "$($('#iframe')[0].contentDocument).scrollLeft()" );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
})();
|
||||
} )();
|
||||
|
||||
@@ -1,240 +1,241 @@
|
||||
QUnit.module( "queue", { teardown: moduleTeardown });
|
||||
QUnit.module( "queue", { teardown: moduleTeardown } );
|
||||
|
||||
QUnit.test( "queue() with other types", function( assert ) {
|
||||
assert.expect( 14 );
|
||||
|
||||
QUnit.stop();
|
||||
|
||||
var $div = jQuery({}),
|
||||
var $div = jQuery( {} ),
|
||||
counter = 0;
|
||||
|
||||
$div.promise( "foo" ).done(function() {
|
||||
$div.promise( "foo" ).done( function() {
|
||||
assert.equal( counter, 0, "Deferred for collection with no queue is automatically resolved" );
|
||||
});
|
||||
} );
|
||||
|
||||
$div
|
||||
.queue("foo",function(){
|
||||
.queue( "foo", function() {
|
||||
assert.equal( ++counter, 1, "Dequeuing" );
|
||||
jQuery.dequeue(this,"foo");
|
||||
})
|
||||
.queue("foo",function(){
|
||||
jQuery.dequeue( this, "foo" );
|
||||
} )
|
||||
.queue( "foo", function() {
|
||||
assert.equal( ++counter, 2, "Dequeuing" );
|
||||
jQuery(this).dequeue("foo");
|
||||
})
|
||||
.queue("foo",function(){
|
||||
jQuery( this ).dequeue( "foo" );
|
||||
} )
|
||||
.queue( "foo", function() {
|
||||
assert.equal( ++counter, 3, "Dequeuing" );
|
||||
})
|
||||
.queue("foo",function(){
|
||||
} )
|
||||
.queue( "foo", function() {
|
||||
assert.equal( ++counter, 4, "Dequeuing" );
|
||||
});
|
||||
} );
|
||||
|
||||
$div.promise("foo").done(function() {
|
||||
$div.promise( "foo" ).done( function() {
|
||||
assert.equal( counter, 4, "Testing previous call to dequeue in deferred" );
|
||||
QUnit.start();
|
||||
});
|
||||
} );
|
||||
|
||||
assert.equal( $div.queue("foo").length, 4, "Testing queue length" );
|
||||
assert.equal( $div.queue( "foo" ).length, 4, "Testing queue length" );
|
||||
|
||||
assert.equal( $div.queue("foo", undefined).queue("foo").length, 4, ".queue('name',undefined) does nothing but is chainable (#5571)");
|
||||
assert.equal( $div.queue( "foo", undefined ).queue( "foo" ).length, 4, ".queue('name',undefined) does nothing but is chainable (#5571)" );
|
||||
|
||||
$div.dequeue("foo");
|
||||
$div.dequeue( "foo" );
|
||||
|
||||
assert.equal( counter, 3, "Testing previous call to dequeue" );
|
||||
assert.equal( $div.queue("foo").length, 1, "Testing queue length" );
|
||||
assert.equal( $div.queue( "foo" ).length, 1, "Testing queue length" );
|
||||
|
||||
$div.dequeue("foo");
|
||||
$div.dequeue( "foo" );
|
||||
|
||||
assert.equal( counter, 4, "Testing previous call to dequeue" );
|
||||
assert.equal( $div.queue("foo").length, 0, "Testing queue length" );
|
||||
assert.equal( $div.queue( "foo" ).length, 0, "Testing queue length" );
|
||||
|
||||
$div.dequeue("foo");
|
||||
$div.dequeue( "foo" );
|
||||
|
||||
assert.equal( counter, 4, "Testing previous call to dequeue" );
|
||||
assert.equal( $div.queue("foo").length, 0, "Testing queue length" );
|
||||
assert.equal( $div.queue( "foo" ).length, 0, "Testing queue length" );
|
||||
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("queue(name) passes in the next item in the queue as a parameter", function( assert ) {
|
||||
assert.expect(2);
|
||||
QUnit.test( "queue(name) passes in the next item in the queue as a parameter", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var div = jQuery({}),
|
||||
var div = jQuery( {} ),
|
||||
counter = 0;
|
||||
|
||||
div.queue("foo", function(next) {
|
||||
assert.equal(++counter, 1, "Dequeueing");
|
||||
div.queue( "foo", function( next ) {
|
||||
assert.equal( ++counter, 1, "Dequeueing" );
|
||||
next();
|
||||
}).queue("foo", function(next) {
|
||||
assert.equal(++counter, 2, "Next was called");
|
||||
} ).queue( "foo", function( next ) {
|
||||
assert.equal( ++counter, 2, "Next was called" );
|
||||
next();
|
||||
}).queue("bar", function() {
|
||||
assert.equal(++counter, 3, "Other queues are not triggered by next()");
|
||||
});
|
||||
} ).queue( "bar", function() {
|
||||
assert.equal( ++counter, 3, "Other queues are not triggered by next()" );
|
||||
} );
|
||||
|
||||
div.dequeue("foo");
|
||||
});
|
||||
div.dequeue( "foo" );
|
||||
} );
|
||||
|
||||
QUnit.test("queue() passes in the next item in the queue as a parameter to fx queues", function( assert ) {
|
||||
assert.expect(3);
|
||||
QUnit.test( "queue() passes in the next item in the queue as a parameter to fx queues", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
QUnit.stop();
|
||||
|
||||
var div = jQuery({}),
|
||||
var div = jQuery( {} ),
|
||||
counter = 0;
|
||||
|
||||
div.queue(function(next) {
|
||||
assert.equal(++counter, 1, "Dequeueing");
|
||||
setTimeout(function() { next(); }, 500);
|
||||
}).queue(function(next) {
|
||||
assert.equal(++counter, 2, "Next was called");
|
||||
div.queue( function( next ) {
|
||||
assert.equal( ++counter, 1, "Dequeueing" );
|
||||
setTimeout( function() { next(); }, 500 );
|
||||
} ).queue( function( next ) {
|
||||
assert.equal( ++counter, 2, "Next was called" );
|
||||
next();
|
||||
}).queue("bar", function() {
|
||||
assert.equal(++counter, 3, "Other queues are not triggered by next()");
|
||||
});
|
||||
} ).queue( "bar", function() {
|
||||
assert.equal( ++counter, 3, "Other queues are not triggered by next()" );
|
||||
} );
|
||||
|
||||
jQuery.when( div.promise("fx"), div ).done(function() {
|
||||
assert.equal(counter, 2, "Deferreds resolved");
|
||||
jQuery.when( div.promise( "fx" ), div ).done( function() {
|
||||
assert.equal( counter, 2, "Deferreds resolved" );
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test("callbacks keep their place in the queue", function( assert ) {
|
||||
assert.expect(5);
|
||||
QUnit.test( "callbacks keep their place in the queue", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
QUnit.stop();
|
||||
var div = jQuery("<div>"),
|
||||
var div = jQuery( "<div>" ),
|
||||
counter = 0;
|
||||
|
||||
div.queue(function( next ) {
|
||||
div.queue( function( next ) {
|
||||
assert.equal( ++counter, 1, "Queue/callback order: first called" );
|
||||
setTimeout( next, 200 );
|
||||
}).delay( 100 ).queue(function( next ) {
|
||||
} ).delay( 100 ).queue( function( next ) {
|
||||
assert.equal( ++counter, 2, "Queue/callback order: second called" );
|
||||
jQuery( this ).delay( 100 ).queue(function( next ) {
|
||||
jQuery( this ).delay( 100 ).queue( function( next ) {
|
||||
assert.equal( ++counter, 4, "Queue/callback order: fourth called" );
|
||||
next();
|
||||
});
|
||||
} );
|
||||
next();
|
||||
}).queue(function( next ) {
|
||||
} ).queue( function( next ) {
|
||||
assert.equal( ++counter, 3, "Queue/callback order: third called" );
|
||||
next();
|
||||
});
|
||||
} );
|
||||
|
||||
div.promise("fx").done(function() {
|
||||
assert.equal(counter, 4, "Deferreds resolved");
|
||||
div.promise( "fx" ).done( function() {
|
||||
assert.equal( counter, 4, "Deferreds resolved" );
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.queue should return array while manipulating the queue", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var div = document.createElement("div");
|
||||
var div = document.createElement( "div" );
|
||||
|
||||
assert.ok( jQuery.isArray( jQuery.queue( div, "fx", jQuery.noop ) ), "jQuery.queue should return an array while manipulating the queue" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("delay()", function( assert ) {
|
||||
assert.expect(2);
|
||||
QUnit.test( "delay()", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
QUnit.stop();
|
||||
|
||||
var foo = jQuery({}), run = 0;
|
||||
var foo = jQuery( {} ), run = 0;
|
||||
|
||||
foo.delay(100).queue(function(){
|
||||
foo.delay( 100 ).queue( function() {
|
||||
run = 1;
|
||||
assert.ok( true, "The function was dequeued." );
|
||||
QUnit.start();
|
||||
});
|
||||
} );
|
||||
|
||||
assert.equal( run, 0, "The delay delayed the next function from running." );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("clearQueue(name) clears the queue", function( assert ) {
|
||||
assert.expect(2);
|
||||
QUnit.test( "clearQueue(name) clears the queue", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
QUnit.stop();
|
||||
|
||||
var div = jQuery({}),
|
||||
var div = jQuery( {} ),
|
||||
counter = 0;
|
||||
|
||||
div.queue("foo", function( next ) {
|
||||
div.queue( "foo", function( next ) {
|
||||
counter++;
|
||||
jQuery(this).clearQueue("foo");
|
||||
jQuery( this ).clearQueue( "foo" );
|
||||
next();
|
||||
}).queue("foo", function() {
|
||||
} ).queue( "foo", function() {
|
||||
counter++;
|
||||
});
|
||||
} );
|
||||
|
||||
div.promise("foo").done(function() {
|
||||
div.promise( "foo" ).done( function() {
|
||||
assert.ok( true, "dequeue resolves the deferred" );
|
||||
QUnit.start();
|
||||
});
|
||||
} );
|
||||
|
||||
div.dequeue("foo");
|
||||
div.dequeue( "foo" );
|
||||
|
||||
assert.equal(counter, 1, "the queue was cleared");
|
||||
});
|
||||
assert.equal( counter, 1, "the queue was cleared" );
|
||||
} );
|
||||
|
||||
QUnit.test("clearQueue() clears the fx queue", function( assert ) {
|
||||
assert.expect(1);
|
||||
QUnit.test( "clearQueue() clears the fx queue", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var div = jQuery({}),
|
||||
var div = jQuery( {} ),
|
||||
counter = 0;
|
||||
|
||||
div.queue(function( next ) {
|
||||
div.queue( function( next ) {
|
||||
counter++;
|
||||
var self = this;
|
||||
setTimeout(function() { jQuery(self).clearQueue(); next(); }, 50);
|
||||
}).queue(function() {
|
||||
setTimeout( function() { jQuery( self ).clearQueue(); next(); }, 50 );
|
||||
} ).queue( function() {
|
||||
counter++;
|
||||
});
|
||||
} );
|
||||
|
||||
assert.equal(counter, 1, "the queue was cleared");
|
||||
assert.equal( counter, 1, "the queue was cleared" );
|
||||
|
||||
div.removeData();
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.asyncTest( "fn.promise() - called when fx queue is empty", 3, function( assert ) {
|
||||
var foo = jQuery( "#foo" ).clone().addBack(),
|
||||
promised = false;
|
||||
|
||||
foo.queue( function( next ) {
|
||||
|
||||
// called twice!
|
||||
assert.ok( !promised, "Promised hasn't been called" );
|
||||
setTimeout( next, 10 );
|
||||
});
|
||||
} );
|
||||
foo.promise().done( function() {
|
||||
assert.ok( promised = true, "Promised" );
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.asyncTest( "fn.promise( \"queue\" ) - called whenever last queue function is dequeued", 5, function( assert ) {
|
||||
var foo = jQuery( "#foo" ),
|
||||
test;
|
||||
foo.promise( "queue" ).done( function() {
|
||||
assert.strictEqual( test, undefined, "called immediately when queue was already empty" );
|
||||
});
|
||||
} );
|
||||
test = 1;
|
||||
foo.queue( "queue", function( next ) {
|
||||
assert.strictEqual( test++, 1, "step one" );
|
||||
setTimeout( next, 0 );
|
||||
}).queue( "queue", function( next ) {
|
||||
} ).queue( "queue", function( next ) {
|
||||
assert.strictEqual( test++, 2, "step two" );
|
||||
setTimeout( function() {
|
||||
next();
|
||||
assert.strictEqual( test++, 4, "step four" );
|
||||
QUnit.start();
|
||||
}, 10 );
|
||||
}).promise( "queue" ).done( function() {
|
||||
} ).promise( "queue" ).done( function() {
|
||||
assert.strictEqual( test++, 3, "step three" );
|
||||
});
|
||||
} );
|
||||
|
||||
foo.dequeue( "queue" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", 2, function( assert ) {
|
||||
var foo = jQuery( "#foo" ),
|
||||
test = 1;
|
||||
|
||||
foo.animate({
|
||||
foo.animate( {
|
||||
top: 100
|
||||
}, {
|
||||
duration: 1,
|
||||
@@ -242,43 +243,42 @@ QUnit.asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete befo
|
||||
complete: function() {
|
||||
assert.strictEqual( test++, 1, "step one" );
|
||||
}
|
||||
}).dequeue( "queue" );
|
||||
} ).dequeue( "queue" );
|
||||
|
||||
foo.promise( "queue" ).done( function() {
|
||||
assert.strictEqual( test++, 2, "step two" );
|
||||
QUnit.start();
|
||||
});
|
||||
} );
|
||||
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( ".promise(obj)", function( assert ) {
|
||||
assert.expect(2);
|
||||
assert.expect( 2 );
|
||||
|
||||
var obj = {},
|
||||
promise = jQuery( "#foo" ).promise( "promise", obj );
|
||||
|
||||
assert.ok( jQuery.isFunction( promise.promise ), ".promise(type, obj) returns a promise" );
|
||||
assert.strictEqual( promise, obj, ".promise(type, obj) returns obj" );
|
||||
});
|
||||
|
||||
} );
|
||||
|
||||
if ( jQuery.fn.stop ) {
|
||||
QUnit.test("delay() can be stopped", function( assert ) {
|
||||
QUnit.test( "delay() can be stopped", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
QUnit.stop();
|
||||
|
||||
var done = {};
|
||||
jQuery({})
|
||||
jQuery( {} )
|
||||
.queue( "alternate", function( next ) {
|
||||
done.alt1 = true;
|
||||
assert.ok( true, "This first function was dequeued" );
|
||||
next();
|
||||
})
|
||||
} )
|
||||
.delay( 1000, "alternate" )
|
||||
.queue( "alternate", function() {
|
||||
done.alt2 = true;
|
||||
assert.ok( true, "The function was dequeued immediately, the delay was stopped" );
|
||||
})
|
||||
} )
|
||||
.dequeue( "alternate" )
|
||||
|
||||
// stop( "alternate", false ) will NOT clear the queue, so it should automatically dequeue the next
|
||||
@@ -286,20 +286,20 @@ if ( jQuery.fn.stop ) {
|
||||
|
||||
// this test
|
||||
.delay( 1 )
|
||||
.queue(function() {
|
||||
.queue( function() {
|
||||
done.default1 = true;
|
||||
assert.ok( false, "This queue should never run" );
|
||||
})
|
||||
} )
|
||||
|
||||
// stop( clearQueue ) should clear the queue
|
||||
.stop( true, false );
|
||||
|
||||
assert.deepEqual( done, { alt1: true, alt2: true }, "Queue ran the proper functions" );
|
||||
|
||||
setTimeout(function() {
|
||||
setTimeout( function() {
|
||||
QUnit.start();
|
||||
}, 1500 );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.asyncTest( "queue stop hooks", 2, function( assert ) {
|
||||
var foo = jQuery( "#foo" );
|
||||
@@ -308,7 +308,7 @@ if ( jQuery.fn.stop ) {
|
||||
hooks.stop = function( gotoEnd ) {
|
||||
assert.equal( !!gotoEnd, false, "Stopped without gotoEnd" );
|
||||
};
|
||||
});
|
||||
} );
|
||||
foo.stop();
|
||||
|
||||
foo.queue( function( next, hooks ) {
|
||||
@@ -316,9 +316,9 @@ if ( jQuery.fn.stop ) {
|
||||
assert.equal( gotoEnd, true, "Stopped with gotoEnd" );
|
||||
QUnit.start();
|
||||
};
|
||||
});
|
||||
} );
|
||||
|
||||
foo.stop( false, true );
|
||||
});
|
||||
} );
|
||||
|
||||
} // if ( jQuery.fn.stop )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
QUnit.module( "ready" );
|
||||
|
||||
(function() {
|
||||
( function() {
|
||||
var notYetReady, noEarlyExecution,
|
||||
order = [],
|
||||
args = {};
|
||||
@@ -12,7 +12,7 @@ QUnit.module( "ready" );
|
||||
|
||||
assert.equal( notYetReady, true, "jQuery.isReady should not be true before DOM ready" );
|
||||
assert.equal( jQuery.isReady, true, "jQuery.isReady should be true once DOM is ready" );
|
||||
});
|
||||
} );
|
||||
|
||||
// Create an event handler.
|
||||
function makeHandler( testId ) {
|
||||
@@ -22,7 +22,7 @@ QUnit.module( "ready" );
|
||||
// the correct arg is being passed into the event handler.
|
||||
return function( arg ) {
|
||||
order.push( testId );
|
||||
args[testId] = arg;
|
||||
args[ testId ] = arg;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,6 +65,6 @@ QUnit.module( "ready" );
|
||||
assert.equal( order.pop(), "h", "Event handler should execute immediately" );
|
||||
assert.equal( args.h, jQuery,
|
||||
"Argument passed to fn in jQuery(document).ready( fn ) should be jQuery" );
|
||||
});
|
||||
} );
|
||||
|
||||
})();
|
||||
} )();
|
||||
|
||||
@@ -1,93 +1,93 @@
|
||||
QUnit.module("selector", { teardown: moduleTeardown });
|
||||
QUnit.module( "selector", { teardown: moduleTeardown } );
|
||||
|
||||
/**
|
||||
* This test page is for selector tests that require jQuery in order to do the selection
|
||||
*/
|
||||
|
||||
QUnit.test("element - jQuery only", function( assert ) {
|
||||
QUnit.test( "element - jQuery only", function( assert ) {
|
||||
assert.expect( 7 );
|
||||
|
||||
var fixture = document.getElementById("qunit-fixture");
|
||||
var fixture = document.getElementById( "qunit-fixture" );
|
||||
|
||||
assert.deepEqual( jQuery("p", fixture).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a Node context." );
|
||||
assert.deepEqual( jQuery("p", "#qunit-fixture").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a selector context." );
|
||||
assert.deepEqual( jQuery("p", jQuery("#qunit-fixture")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a jQuery object context." );
|
||||
assert.deepEqual( jQuery("#qunit-fixture").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context via .find()." );
|
||||
assert.deepEqual( jQuery( "p", fixture ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a Node context." );
|
||||
assert.deepEqual( jQuery( "p", "#qunit-fixture" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a selector context." );
|
||||
assert.deepEqual( jQuery( "p", jQuery( "#qunit-fixture" ) ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a jQuery object context." );
|
||||
assert.deepEqual( jQuery( "#qunit-fixture" ).find( "p" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a context via .find()." );
|
||||
|
||||
assert.ok( jQuery("#length").length, "<input name=\"length\"> cannot be found under IE, see #945" );
|
||||
assert.ok( jQuery("#lengthtest input").length, "<input name=\"length\"> cannot be found under IE, see #945" );
|
||||
assert.ok( jQuery( "#length" ).length, "<input name=\"length\"> cannot be found under IE, see #945" );
|
||||
assert.ok( jQuery( "#lengthtest input" ).length, "<input name=\"length\"> cannot be found under IE, see #945" );
|
||||
|
||||
// #7533
|
||||
assert.equal( jQuery("<div id=\"A'B~C.D[E]\"><p>foo</p></div>").find("p").length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" );
|
||||
});
|
||||
assert.equal( jQuery( "<div id=\"A'B~C.D[E]\"><p>foo</p></div>" ).find( "p" ).length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" );
|
||||
} );
|
||||
|
||||
QUnit.test("id", function( assert ) {
|
||||
QUnit.test( "id", function( assert ) {
|
||||
assert.expect( 26 );
|
||||
|
||||
var a;
|
||||
|
||||
t( "ID Selector", "#body", ["body"] );
|
||||
t( "ID Selector w/ Element", "body#body", ["body"] );
|
||||
t( "ID Selector", "#body", [ "body" ] );
|
||||
t( "ID Selector w/ Element", "body#body", [ "body" ] );
|
||||
t( "ID Selector w/ Element", "ul#first", [] );
|
||||
t( "ID selector with existing ID descendant", "#firstp #simon1", ["simon1"] );
|
||||
t( "ID selector with existing ID descendant", "#firstp #simon1", [ "simon1" ] );
|
||||
t( "ID selector with non-existent descendant", "#firstp #foobar", [] );
|
||||
t( "ID selector using UTF8", "#台北Táiběi", ["台北Táiběi"] );
|
||||
t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", ["台北Táiběi","台北"] );
|
||||
t( "Descendant ID selector using UTF8", "div #台北", ["台北"] );
|
||||
t( "Child ID selector using UTF8", "form > #台北", ["台北"] );
|
||||
t( "ID selector using UTF8", "#台北Táiběi", [ "台北Táiběi" ] );
|
||||
t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", [ "台北Táiběi","台北" ] );
|
||||
t( "Descendant ID selector using UTF8", "div #台北", [ "台北" ] );
|
||||
t( "Child ID selector using UTF8", "form > #台北", [ "台北" ] );
|
||||
|
||||
t( "Escaped ID", "#foo\\:bar", ["foo:bar"] );
|
||||
t( "Escaped ID", "#test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
|
||||
t( "Descendant escaped ID", "div #foo\\:bar", ["foo:bar"] );
|
||||
t( "Descendant escaped ID", "div #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
|
||||
t( "Child escaped ID", "form > #foo\\:bar", ["foo:bar"] );
|
||||
t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
|
||||
t( "Escaped ID", "#foo\\:bar", [ "foo:bar" ] );
|
||||
t( "Escaped ID", "#test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
|
||||
t( "Descendant escaped ID", "div #foo\\:bar", [ "foo:bar" ] );
|
||||
t( "Descendant escaped ID", "div #test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
|
||||
t( "Child escaped ID", "form > #foo\\:bar", [ "foo:bar" ] );
|
||||
t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
|
||||
|
||||
t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] ); // bug #267
|
||||
t( "ID Selector, child ID present", "#form > #radio1", [ "radio1" ] ); // bug #267
|
||||
t( "ID Selector, not an ancestor ID", "#form #first", [] );
|
||||
t( "ID Selector, not a child ID", "#form > #option1a", [] );
|
||||
|
||||
t( "All Children of ID", "#foo > *", ["sndp", "en", "sap"] );
|
||||
t( "All Children of ID", "#foo > *", [ "sndp", "en", "sap" ] );
|
||||
t( "All Children of ID with no children", "#firstUL > *", [] );
|
||||
|
||||
a = jQuery("<a id='backslash\\foo'></a>").appendTo("#qunit-fixture");
|
||||
t( "ID Selector contains backslash", "#backslash\\\\foo", ["backslash\\foo"] );
|
||||
a = jQuery( "<a id='backslash\\foo'></a>" ).appendTo( "#qunit-fixture" );
|
||||
t( "ID Selector contains backslash", "#backslash\\\\foo", [ "backslash\\foo" ] );
|
||||
|
||||
t( "ID Selector on Form with an input that has a name of 'id'", "#lengthtest", ["lengthtest"] );
|
||||
t( "ID Selector on Form with an input that has a name of 'id'", "#lengthtest", [ "lengthtest" ] );
|
||||
|
||||
t( "ID selector with non-existent ancestor", "#asdfasdf #foobar", [] ); // bug #986
|
||||
|
||||
t( "Underscore ID", "#types_all", ["types_all"] );
|
||||
t( "Dash ID", "#qunit-fixture", ["qunit-fixture"] );
|
||||
t( "Underscore ID", "#types_all", [ "types_all" ] );
|
||||
t( "Dash ID", "#qunit-fixture", [ "qunit-fixture" ] );
|
||||
|
||||
t( "ID with weird characters in it", "#name\\+value", ["name+value"] );
|
||||
});
|
||||
t( "ID with weird characters in it", "#name\\+value", [ "name+value" ] );
|
||||
} );
|
||||
|
||||
QUnit.test("class - jQuery only", function( assert ) {
|
||||
QUnit.test( "class - jQuery only", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
assert.deepEqual( jQuery(".blog", document.getElementsByTagName("p")).get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
assert.deepEqual( jQuery(".blog", "p").get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
assert.deepEqual( jQuery(".blog", jQuery("p")).get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
assert.deepEqual( jQuery("p").find(".blog").get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
});
|
||||
assert.deepEqual( jQuery( ".blog", document.getElementsByTagName( "p" ) ).get(), q( "mark", "simon" ), "Finding elements with a context." );
|
||||
assert.deepEqual( jQuery( ".blog", "p" ).get(), q( "mark", "simon" ), "Finding elements with a context." );
|
||||
assert.deepEqual( jQuery( ".blog", jQuery( "p" ) ).get(), q( "mark", "simon" ), "Finding elements with a context." );
|
||||
assert.deepEqual( jQuery( "p" ).find( ".blog" ).get(), q( "mark", "simon" ), "Finding elements with a context." );
|
||||
} );
|
||||
|
||||
QUnit.test("name", function( assert ) {
|
||||
QUnit.test( "name", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var form;
|
||||
|
||||
t( "Name selector", "input[name=action]", ["text1"] );
|
||||
t( "Name selector with single quotes", "input[name='action']", ["text1"] );
|
||||
t( "Name selector with double quotes", "input[name=\"action\"]", ["text1"] );
|
||||
t( "Name selector", "input[name=action]", [ "text1" ] );
|
||||
t( "Name selector with single quotes", "input[name='action']", [ "text1" ] );
|
||||
t( "Name selector with double quotes", "input[name=\"action\"]", [ "text1" ] );
|
||||
|
||||
t( "Name selector for grouped input", "input[name='types[]']", ["types_all", "types_anime", "types_movie"] );
|
||||
t( "Name selector for grouped input", "input[name='types[]']", [ "types_all", "types_anime", "types_movie" ] );
|
||||
|
||||
form = jQuery("<form><input name='id'/></form>").appendTo("body");
|
||||
assert.equal( jQuery("input", form[0]).length, 1, "Make sure that rooted queries on forms (with possible expandos) work." );
|
||||
form = jQuery( "<form><input name='id'/></form>" ).appendTo( "body" );
|
||||
assert.equal( jQuery( "input", form[ 0 ] ).length, 1, "Make sure that rooted queries on forms (with possible expandos) work." );
|
||||
|
||||
form.remove();
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "selectors with comma", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
@@ -98,108 +98,108 @@ QUnit.test( "selectors with comma", function( assert ) {
|
||||
assert.equal( fixture.find( "h2, div p" ).filter( "h2" ).length, 1, "has to find one <h2>" );
|
||||
assert.equal( fixture.find( "h2 , div p" ).filter( "p" ).length, 2, "has to find two <p>" );
|
||||
assert.equal( fixture.find( "h2 , div p" ).filter( "h2" ).length, 1, "has to find one <h2>" );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "child and adjacent", function( assert ) {
|
||||
assert.expect( 27 );
|
||||
|
||||
var nothiddendiv;
|
||||
|
||||
t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
|
||||
t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
|
||||
t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
|
||||
t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
|
||||
t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
|
||||
t( "All Children", "code > *", ["anchor1","anchor2"] );
|
||||
t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
|
||||
t( "Adjacent", "p + p", ["ap","en","sap"] );
|
||||
t( "Adjacent", "p#firstp + p", ["ap"] );
|
||||
t( "Adjacent", "p[lang=en] + p", ["sap"] );
|
||||
t( "Adjacent", "a.GROUPS + code + a", ["mark"] );
|
||||
t( "Element Preceded By", "#groups ~ a", ["mark"] );
|
||||
t( "Element Preceded By", "#length ~ input", ["idTest"] );
|
||||
t( "Element Preceded By", "#siblingfirst ~ em", ["siblingnext", "siblingthird"] );
|
||||
t( "Element Preceded By (multiple)", "#siblingTest em ~ em ~ em ~ span", ["siblingspan"] );
|
||||
t( "Element Preceded By, Containing", "#liveHandlerOrder ~ div em:contains('1')", ["siblingfirst"] );
|
||||
t( "Child", "p > a", [ "simon1","google","groups","mark","yahoo","simon" ] );
|
||||
t( "Child", "p> a", [ "simon1","google","groups","mark","yahoo","simon" ] );
|
||||
t( "Child", "p >a", [ "simon1","google","groups","mark","yahoo","simon" ] );
|
||||
t( "Child", "p>a", [ "simon1","google","groups","mark","yahoo","simon" ] );
|
||||
t( "Child w/ Class", "p > a.blog", [ "mark","simon" ] );
|
||||
t( "All Children", "code > *", [ "anchor1","anchor2" ] );
|
||||
t( "All Grandchildren", "p > * > *", [ "anchor1","anchor2" ] );
|
||||
t( "Adjacent", "p + p", [ "ap","en","sap" ] );
|
||||
t( "Adjacent", "p#firstp + p", [ "ap" ] );
|
||||
t( "Adjacent", "p[lang=en] + p", [ "sap" ] );
|
||||
t( "Adjacent", "a.GROUPS + code + a", [ "mark" ] );
|
||||
t( "Element Preceded By", "#groups ~ a", [ "mark" ] );
|
||||
t( "Element Preceded By", "#length ~ input", [ "idTest" ] );
|
||||
t( "Element Preceded By", "#siblingfirst ~ em", [ "siblingnext", "siblingthird" ] );
|
||||
t( "Element Preceded By (multiple)", "#siblingTest em ~ em ~ em ~ span", [ "siblingspan" ] );
|
||||
t( "Element Preceded By, Containing", "#liveHandlerOrder ~ div em:contains('1')", [ "siblingfirst" ] );
|
||||
|
||||
t( "Multiple combinators selects all levels", "#siblingTest em *", ["siblingchild", "siblinggrandchild", "siblinggreatgrandchild"] );
|
||||
t( "Multiple combinators selects all levels", "#siblingTest > em *", ["siblingchild", "siblinggrandchild", "siblinggreatgrandchild"] );
|
||||
t( "Multiple sibling combinators doesn't miss general siblings", "#siblingTest > em:first-child + em ~ span", ["siblingspan"] );
|
||||
t( "Multiple combinators selects all levels", "#siblingTest em *", [ "siblingchild", "siblinggrandchild", "siblinggreatgrandchild" ] );
|
||||
t( "Multiple combinators selects all levels", "#siblingTest > em *", [ "siblingchild", "siblinggrandchild", "siblinggreatgrandchild" ] );
|
||||
t( "Multiple sibling combinators doesn't miss general siblings", "#siblingTest > em:first-child + em ~ span", [ "siblingspan" ] );
|
||||
t( "Combinators are not skipped when mixing general and specific", "#siblingTest > em:contains('x') + em ~ span", [] );
|
||||
|
||||
assert.equal( jQuery("#listWithTabIndex").length, 1, "Parent div for next test is found via ID (#8310)" );
|
||||
assert.equal( jQuery("#listWithTabIndex li:eq(2) ~ li").length, 1, "Find by general sibling combinator (#8310)" );
|
||||
assert.equal( jQuery("#__sizzle__").length, 0, "Make sure the temporary id assigned by sizzle is cleared out (#8310)" );
|
||||
assert.equal( jQuery("#listWithTabIndex").length, 1, "Parent div for previous test is still found via ID (#8310)" );
|
||||
assert.equal( jQuery( "#listWithTabIndex" ).length, 1, "Parent div for next test is found via ID (#8310)" );
|
||||
assert.equal( jQuery( "#listWithTabIndex li:eq(2) ~ li" ).length, 1, "Find by general sibling combinator (#8310)" );
|
||||
assert.equal( jQuery( "#__sizzle__" ).length, 0, "Make sure the temporary id assigned by sizzle is cleared out (#8310)" );
|
||||
assert.equal( jQuery( "#listWithTabIndex" ).length, 1, "Parent div for previous test is still found via ID (#8310)" );
|
||||
|
||||
t( "Verify deep class selector", "div.blah > p > a", [] );
|
||||
|
||||
t( "No element deep selector", "div.foo > span > a", [] );
|
||||
|
||||
nothiddendiv = document.getElementById("nothiddendiv");
|
||||
nothiddendiv = document.getElementById( "nothiddendiv" );
|
||||
|
||||
t( "Non-existent ancestors", ".fototab > .thumbnails > a", [] );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("attributes", function( assert ) {
|
||||
QUnit.test( "attributes", function( assert ) {
|
||||
assert.expect( 54 );
|
||||
|
||||
var attrbad, div, withScript;
|
||||
|
||||
t( "Find elements with a tabindex attribute", "[tabindex]", ["listWithTabIndex", "foodWithNegativeTabIndex", "linkWithTabIndex", "linkWithNegativeTabIndex", "linkWithNoHrefWithTabIndex", "linkWithNoHrefWithNegativeTabIndex"] );
|
||||
t( "Find elements with a tabindex attribute", "[tabindex]", [ "listWithTabIndex", "foodWithNegativeTabIndex", "linkWithTabIndex", "linkWithNegativeTabIndex", "linkWithNoHrefWithTabIndex", "linkWithNoHrefWithNegativeTabIndex" ] );
|
||||
|
||||
t( "Attribute Exists", "#qunit-fixture a[title]", ["google"] );
|
||||
t( "Attribute Exists (case-insensitive)", "#qunit-fixture a[TITLE]", ["google"] );
|
||||
t( "Attribute Exists", "#qunit-fixture *[title]", ["google"] );
|
||||
t( "Attribute Exists", "#qunit-fixture [title]", ["google"] );
|
||||
t( "Attribute Exists", "#qunit-fixture a[ title ]", ["google"] );
|
||||
t( "Attribute Exists", "#qunit-fixture a[title]", [ "google" ] );
|
||||
t( "Attribute Exists (case-insensitive)", "#qunit-fixture a[TITLE]", [ "google" ] );
|
||||
t( "Attribute Exists", "#qunit-fixture *[title]", [ "google" ] );
|
||||
t( "Attribute Exists", "#qunit-fixture [title]", [ "google" ] );
|
||||
t( "Attribute Exists", "#qunit-fixture a[ title ]", [ "google" ] );
|
||||
|
||||
t( "Boolean attribute exists", "#select2 option[selected]", ["option2d"]);
|
||||
t( "Boolean attribute equals", "#select2 option[selected='selected']", ["option2d"]);
|
||||
t( "Boolean attribute exists", "#select2 option[selected]", [ "option2d" ] );
|
||||
t( "Boolean attribute equals", "#select2 option[selected='selected']", [ "option2d" ] );
|
||||
|
||||
t( "Attribute Equals", "#qunit-fixture a[rel='bookmark']", ["simon1"] );
|
||||
t( "Attribute Equals", "#qunit-fixture a[rel='bookmark']", ["simon1"] );
|
||||
t( "Attribute Equals", "#qunit-fixture a[rel=bookmark]", ["simon1"] );
|
||||
t( "Attribute Equals", "#qunit-fixture a[href='http://www.google.com/']", ["google"] );
|
||||
t( "Attribute Equals", "#qunit-fixture a[ rel = 'bookmark' ]", ["simon1"] );
|
||||
t( "Attribute Equals Number", "#qunit-fixture option[value=1]", ["option1b","option2b","option3b","option4b","option5c"] );
|
||||
t( "Attribute Equals Number", "#qunit-fixture li[tabIndex=-1]", ["foodWithNegativeTabIndex"] );
|
||||
t( "Attribute Equals", "#qunit-fixture a[rel='bookmark']", [ "simon1" ] );
|
||||
t( "Attribute Equals", "#qunit-fixture a[rel='bookmark']", [ "simon1" ] );
|
||||
t( "Attribute Equals", "#qunit-fixture a[rel=bookmark]", [ "simon1" ] );
|
||||
t( "Attribute Equals", "#qunit-fixture a[href='http://www.google.com/']", [ "google" ] );
|
||||
t( "Attribute Equals", "#qunit-fixture a[ rel = 'bookmark' ]", [ "simon1" ] );
|
||||
t( "Attribute Equals Number", "#qunit-fixture option[value=1]", [ "option1b","option2b","option3b","option4b","option5c" ] );
|
||||
t( "Attribute Equals Number", "#qunit-fixture li[tabIndex=-1]", [ "foodWithNegativeTabIndex" ] );
|
||||
|
||||
document.getElementById("anchor2").href = "#2";
|
||||
t( "href Attribute", "p a[href^='#']", ["anchor2"] );
|
||||
t( "href Attribute", "p a[href*='#']", ["simon1", "anchor2"] );
|
||||
document.getElementById( "anchor2" ).href = "#2";
|
||||
t( "href Attribute", "p a[href^='#']", [ "anchor2" ] );
|
||||
t( "href Attribute", "p a[href*='#']", [ "simon1", "anchor2" ] );
|
||||
|
||||
t( "for Attribute", "form label[for]", ["label-for"] );
|
||||
t( "for Attribute in form", "#form [for=action]", ["label-for"] );
|
||||
t( "for Attribute", "form label[for]", [ "label-for" ] );
|
||||
t( "for Attribute in form", "#form [for=action]", [ "label-for" ] );
|
||||
|
||||
t( "Attribute containing []", "input[name^='foo[']", ["hidden2"] );
|
||||
t( "Attribute containing []", "input[name^='foo[bar]']", ["hidden2"] );
|
||||
t( "Attribute containing []", "input[name*='[bar]']", ["hidden2"] );
|
||||
t( "Attribute containing []", "input[name$='bar]']", ["hidden2"] );
|
||||
t( "Attribute containing []", "input[name$='[bar]']", ["hidden2"] );
|
||||
t( "Attribute containing []", "input[name$='foo[bar]']", ["hidden2"] );
|
||||
t( "Attribute containing []", "input[name*='foo[bar]']", ["hidden2"] );
|
||||
t( "Attribute containing []", "input[name^='foo[']", [ "hidden2" ] );
|
||||
t( "Attribute containing []", "input[name^='foo[bar]']", [ "hidden2" ] );
|
||||
t( "Attribute containing []", "input[name*='[bar]']", [ "hidden2" ] );
|
||||
t( "Attribute containing []", "input[name$='bar]']", [ "hidden2" ] );
|
||||
t( "Attribute containing []", "input[name$='[bar]']", [ "hidden2" ] );
|
||||
t( "Attribute containing []", "input[name$='foo[bar]']", [ "hidden2" ] );
|
||||
t( "Attribute containing []", "input[name*='foo[bar]']", [ "hidden2" ] );
|
||||
|
||||
t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type='hidden']", ["radio1", "radio2", "hidden1"] );
|
||||
t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type=\"hidden\"]", ["radio1", "radio2", "hidden1"] );
|
||||
t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type=hidden]", ["radio1", "radio2", "hidden1"] );
|
||||
t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type='hidden']", [ "radio1", "radio2", "hidden1" ] );
|
||||
t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type=\"hidden\"]", [ "radio1", "radio2", "hidden1" ] );
|
||||
t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type=hidden]", [ "radio1", "radio2", "hidden1" ] );
|
||||
|
||||
t( "Attribute selector using UTF8", "span[lang=中文]", ["台北"] );
|
||||
t( "Attribute selector using UTF8", "span[lang=中文]", [ "台北" ] );
|
||||
|
||||
t( "Attribute Begins With", "a[href ^= 'http://www']", ["google","yahoo"] );
|
||||
t( "Attribute Ends With", "a[href $= 'org/']", ["mark"] );
|
||||
t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] );
|
||||
t( "Attribute Is Not Equal", "#ap a[hreflang!='en']", ["google","groups","anchor1"] );
|
||||
t( "Attribute Begins With", "a[href ^= 'http://www']", [ "google","yahoo" ] );
|
||||
t( "Attribute Ends With", "a[href $= 'org/']", [ "mark" ] );
|
||||
t( "Attribute Contains", "a[href *= 'google']", [ "google","groups" ] );
|
||||
t( "Attribute Is Not Equal", "#ap a[hreflang!='en']", [ "google","groups","anchor1" ] );
|
||||
|
||||
t( "Empty values", "#select1 option[value='']", ["option1a"] );
|
||||
t( "Empty values", "#select1 option[value!='']", ["option1b","option1c","option1d"] );
|
||||
t( "Empty values", "#select1 option[value='']", [ "option1a" ] );
|
||||
t( "Empty values", "#select1 option[value!='']", [ "option1b","option1c","option1d" ] );
|
||||
|
||||
t( "Select options via :selected", "#select1 option:selected", ["option1a"] );
|
||||
t( "Select options via :selected", "#select2 option:selected", ["option2d"] );
|
||||
t( "Select options via :selected", "#select3 option:selected", ["option3b", "option3c"] );
|
||||
t( "Select options via :selected", "select[name='select2'] option:selected", ["option2d"] );
|
||||
t( "Select options via :selected", "#select1 option:selected", [ "option1a" ] );
|
||||
t( "Select options via :selected", "#select2 option:selected", [ "option2d" ] );
|
||||
t( "Select options via :selected", "#select3 option:selected", [ "option3b", "option3c" ] );
|
||||
t( "Select options via :selected", "select[name='select2'] option:selected", [ "option2d" ] );
|
||||
|
||||
t( "Grouped Form Elements", "input[name='foo[bar]']", ["hidden2"] );
|
||||
t( "Grouped Form Elements", "input[name='foo[bar]']", [ "hidden2" ] );
|
||||
|
||||
// Make sure attribute value quoting works correctly. See jQuery #6093; #6428; #13894
|
||||
// Use seeded results to bypass querySelectorAll optimizations
|
||||
@@ -213,63 +213,63 @@ QUnit.test("attributes", function( assert ) {
|
||||
"<input type='hidden' id='attrbad_backslash_quote' data-attr='\''/>" +
|
||||
"<input type='hidden' id='attrbad_backslash_backslash' data-attr='\\'/>" +
|
||||
"<input type='hidden' id='attrbad_unicode' data-attr='一'/>"
|
||||
).appendTo("#qunit-fixture").get();
|
||||
).appendTo( "#qunit-fixture" ).get();
|
||||
|
||||
t( "Underscores don't need escaping", "input[id=types_all]", ["types_all"] );
|
||||
t( "Underscores don't need escaping", "input[id=types_all]", [ "types_all" ] );
|
||||
|
||||
t( "input[type=text]", "#form input[type=text]", ["text1", "text2", "hidden2", "name"] );
|
||||
t( "input[type=search]", "#form input[type=search]", ["search"] );
|
||||
t( "input[type=text]", "#form input[type=text]", [ "text1", "text2", "hidden2", "name" ] );
|
||||
t( "input[type=search]", "#form input[type=search]", [ "search" ] );
|
||||
|
||||
withScript = supportjQuery( "<div><span><script src=''/></span></div>" );
|
||||
assert.ok( withScript.find( "#moretests script[src]" ).has( "script" ), "script[src] (jQuery #13777)" );
|
||||
|
||||
div = document.getElementById("foo");
|
||||
div = document.getElementById( "foo" );
|
||||
t( "Object.prototype property \"constructor\" (negative)", "[constructor]", [] );
|
||||
t( "Gecko Object.prototype property \"watch\" (negative)", "[watch]", [] );
|
||||
div.setAttribute( "constructor", "foo" );
|
||||
div.setAttribute( "watch", "bar" );
|
||||
t( "Object.prototype property \"constructor\"", "[constructor='foo']", ["foo"] );
|
||||
t( "Gecko Object.prototype property \"watch\"", "[watch='bar']", ["foo"] );
|
||||
t( "Object.prototype property \"constructor\"", "[constructor='foo']", [ "foo" ] );
|
||||
t( "Gecko Object.prototype property \"watch\"", "[watch='bar']", [ "foo" ] );
|
||||
|
||||
t( "Value attribute is retrieved correctly", "input[value=Test]", ["text1", "text2"] );
|
||||
t( "Value attribute is retrieved correctly", "input[value=Test]", [ "text1", "text2" ] );
|
||||
|
||||
// #12600
|
||||
assert.ok(
|
||||
jQuery("<select value='12600'><option value='option' selected='selected'></option><option value=''></option></select>")
|
||||
jQuery( "<select value='12600'><option value='option' selected='selected'></option><option value=''></option></select>" )
|
||||
.prop( "value", "option" )
|
||||
.is(":input[value='12600']"),
|
||||
.is( ":input[value='12600']" ),
|
||||
|
||||
":input[value=foo] selects select by attribute"
|
||||
);
|
||||
assert.ok( jQuery("<input type='text' value='12600'/>").prop( "value", "option" ).is(":input[value='12600']"),
|
||||
assert.ok( jQuery( "<input type='text' value='12600'/>" ).prop( "value", "option" ).is( ":input[value='12600']" ),
|
||||
":input[value=foo] selects text input by attribute"
|
||||
);
|
||||
|
||||
// #11115
|
||||
assert.ok( jQuery("<input type='checkbox' checked='checked'/>").prop( "checked", false ).is("[checked]"),
|
||||
assert.ok( jQuery( "<input type='checkbox' checked='checked'/>" ).prop( "checked", false ).is( "[checked]" ),
|
||||
"[checked] selects by attribute (positive)"
|
||||
);
|
||||
assert.ok( !jQuery("<input type='checkbox'/>").prop( "checked", true ).is("[checked]"),
|
||||
assert.ok( !jQuery( "<input type='checkbox'/>" ).prop( "checked", true ).is( "[checked]" ),
|
||||
"[checked] selects by attribute (negative)"
|
||||
);
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("disconnected nodes", function( assert ) {
|
||||
QUnit.test( "disconnected nodes", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var $div = jQuery("<div/>");
|
||||
assert.equal( $div.is("div"), true, "Make sure .is('nodeName') works on disconnected nodes." );
|
||||
});
|
||||
var $div = jQuery( "<div/>" );
|
||||
assert.equal( $div.is( "div" ), true, "Make sure .is('nodeName') works on disconnected nodes." );
|
||||
} );
|
||||
|
||||
QUnit.test("disconnected nodes - jQuery only", function( assert ) {
|
||||
QUnit.test( "disconnected nodes - jQuery only", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var $opt = jQuery("<option></option>").attr("value", "whipit").appendTo("#qunit-fixture").detach();
|
||||
var $opt = jQuery( "<option></option>" ).attr( "value", "whipit" ).appendTo( "#qunit-fixture" ).detach();
|
||||
assert.equal( $opt.val(), "whipit", "option value" );
|
||||
assert.equal( $opt.is(":selected"), false, "unselected option" );
|
||||
$opt.prop("selected", true);
|
||||
assert.equal( $opt.is(":selected"), true, "selected option" );
|
||||
});
|
||||
assert.equal( $opt.is( ":selected" ), false, "unselected option" );
|
||||
$opt.prop( "selected", true );
|
||||
assert.equal( $opt.is( ":selected" ), true, "selected option" );
|
||||
} );
|
||||
|
||||
testIframe(
|
||||
"selector/html5_selector",
|
||||
@@ -286,7 +286,7 @@ testIframe(
|
||||
i = 0;
|
||||
|
||||
for ( ; i < arguments.length; i++ ) {
|
||||
r.push( document.getElementById( arguments[i] ) );
|
||||
r.push( document.getElementById( arguments[ i ] ) );
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -299,15 +299,15 @@ testIframe(
|
||||
* @param {Array} c - Array of ids to construct what is expected
|
||||
*/
|
||||
function t( a, b, c ) {
|
||||
var f = jQuery(b).get(),
|
||||
var f = jQuery( b ).get(),
|
||||
s = "",
|
||||
i = 0;
|
||||
|
||||
for ( ; i < f.length; i++ ) {
|
||||
s += (s && ",") + "'" + f[i].id + "'";
|
||||
s += ( s && "," ) + "'" + f[ i ].id + "'";
|
||||
}
|
||||
|
||||
assert.deepEqual(f, q.apply( q, c ), a + " (" + b + ")");
|
||||
assert.deepEqual( f, q.apply( q, c ), a + " (" + b + ")" );
|
||||
}
|
||||
|
||||
// ====== All known boolean attributes, including html5 booleans ======
|
||||
@@ -318,79 +318,79 @@ testIframe(
|
||||
// noshade, nowrap, novalidate, open, pubdate, readonly, required,
|
||||
// reversed, scoped, seamless, selected, truespeed, visible (skipping visible attribute, which is on a barprop object)
|
||||
|
||||
t( "Attribute Exists", "[autobuffer]", ["video1"]);
|
||||
t( "Attribute Exists", "[autofocus]", ["text1"]);
|
||||
t( "Attribute Exists", "[autoplay]", ["video1"]);
|
||||
t( "Attribute Exists", "[async]", ["script1"]);
|
||||
t( "Attribute Exists", "[checked]", ["check1"]);
|
||||
t( "Attribute Exists", "[compact]", ["dl"]);
|
||||
t( "Attribute Exists", "[controls]", ["video1"]);
|
||||
t( "Attribute Exists", "[declare]", ["object1"]);
|
||||
t( "Attribute Exists", "[defer]", ["script1"]);
|
||||
t( "Attribute Exists", "[disabled]", ["check1"]);
|
||||
t( "Attribute Exists", "[formnovalidate]", ["form1"]);
|
||||
t( "Attribute Exists", "[hidden]", ["div1"]);
|
||||
t( "Attribute Exists", "[indeterminate]", []);
|
||||
t( "Attribute Exists", "[ismap]", ["img1"]);
|
||||
t( "Attribute Exists", "[itemscope]", ["div1"]);
|
||||
t( "Attribute Exists", "[loop]", ["video1"]);
|
||||
t( "Attribute Exists", "[multiple]", ["select1"]);
|
||||
t( "Attribute Exists", "[muted]", ["audio1"]);
|
||||
t( "Attribute Exists", "[nohref]", ["area1"]);
|
||||
t( "Attribute Exists", "[noresize]", ["textarea1"]);
|
||||
t( "Attribute Exists", "[noshade]", ["hr1"]);
|
||||
t( "Attribute Exists", "[nowrap]", ["td1", "div1"]);
|
||||
t( "Attribute Exists", "[novalidate]", ["form1"]);
|
||||
t( "Attribute Exists", "[open]", ["details1"]);
|
||||
t( "Attribute Exists", "[pubdate]", ["article1"]);
|
||||
t( "Attribute Exists", "[readonly]", ["text1"]);
|
||||
t( "Attribute Exists", "[required]", ["text1"]);
|
||||
t( "Attribute Exists", "[reversed]", ["ol1"]);
|
||||
t( "Attribute Exists", "[scoped]", ["style1"]);
|
||||
t( "Attribute Exists", "[seamless]", ["iframe1"]);
|
||||
t( "Attribute Exists", "[selected]", ["option1"]);
|
||||
t( "Attribute Exists", "[truespeed]", ["marquee1"]);
|
||||
t( "Attribute Exists", "[autobuffer]", [ "video1" ] );
|
||||
t( "Attribute Exists", "[autofocus]", [ "text1" ] );
|
||||
t( "Attribute Exists", "[autoplay]", [ "video1" ] );
|
||||
t( "Attribute Exists", "[async]", [ "script1" ] );
|
||||
t( "Attribute Exists", "[checked]", [ "check1" ] );
|
||||
t( "Attribute Exists", "[compact]", [ "dl" ] );
|
||||
t( "Attribute Exists", "[controls]", [ "video1" ] );
|
||||
t( "Attribute Exists", "[declare]", [ "object1" ] );
|
||||
t( "Attribute Exists", "[defer]", [ "script1" ] );
|
||||
t( "Attribute Exists", "[disabled]", [ "check1" ] );
|
||||
t( "Attribute Exists", "[formnovalidate]", [ "form1" ] );
|
||||
t( "Attribute Exists", "[hidden]", [ "div1" ] );
|
||||
t( "Attribute Exists", "[indeterminate]", [] );
|
||||
t( "Attribute Exists", "[ismap]", [ "img1" ] );
|
||||
t( "Attribute Exists", "[itemscope]", [ "div1" ] );
|
||||
t( "Attribute Exists", "[loop]", [ "video1" ] );
|
||||
t( "Attribute Exists", "[multiple]", [ "select1" ] );
|
||||
t( "Attribute Exists", "[muted]", [ "audio1" ] );
|
||||
t( "Attribute Exists", "[nohref]", [ "area1" ] );
|
||||
t( "Attribute Exists", "[noresize]", [ "textarea1" ] );
|
||||
t( "Attribute Exists", "[noshade]", [ "hr1" ] );
|
||||
t( "Attribute Exists", "[nowrap]", [ "td1", "div1" ] );
|
||||
t( "Attribute Exists", "[novalidate]", [ "form1" ] );
|
||||
t( "Attribute Exists", "[open]", [ "details1" ] );
|
||||
t( "Attribute Exists", "[pubdate]", [ "article1" ] );
|
||||
t( "Attribute Exists", "[readonly]", [ "text1" ] );
|
||||
t( "Attribute Exists", "[required]", [ "text1" ] );
|
||||
t( "Attribute Exists", "[reversed]", [ "ol1" ] );
|
||||
t( "Attribute Exists", "[scoped]", [ "style1" ] );
|
||||
t( "Attribute Exists", "[seamless]", [ "iframe1" ] );
|
||||
t( "Attribute Exists", "[selected]", [ "option1" ] );
|
||||
t( "Attribute Exists", "[truespeed]", [ "marquee1" ] );
|
||||
|
||||
// Enumerated attributes (these are not boolean content attributes)
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach([ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) {
|
||||
t( "Enumerated attribute", "[" + val + "]", ["div1"]);
|
||||
});
|
||||
t( "Enumerated attribute", "[spellcheck]", ["span1"]);
|
||||
jQuery.expandedEach( [ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) {
|
||||
t( "Enumerated attribute", "[" + val + "]", [ "div1" ] );
|
||||
} );
|
||||
t( "Enumerated attribute", "[spellcheck]", [ "span1" ] );
|
||||
|
||||
t( "tabindex selector does not retrieve all elements in IE6/7 (#8473)",
|
||||
"form, [tabindex]", [ "form1", "text1" ] );
|
||||
t( "Improperly named form elements do not interfere with form selections (#9570)", "form[name='formName']", ["form1"] );
|
||||
t( "Improperly named form elements do not interfere with form selections (#9570)", "form[name='formName']", [ "form1" ] );
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test( "jQuery.contains", function( assert ) {
|
||||
assert.expect( 16 );
|
||||
|
||||
var container = document.getElementById("nonnodes"),
|
||||
var container = document.getElementById( "nonnodes" ),
|
||||
element = container.firstChild,
|
||||
text = element.nextSibling,
|
||||
nonContained = container.nextSibling,
|
||||
detached = document.createElement("a");
|
||||
detached = document.createElement( "a" );
|
||||
assert.ok( element && element.nodeType === 1, "preliminary: found element" );
|
||||
assert.ok( text && text.nodeType === 3, "preliminary: found text" );
|
||||
assert.ok( nonContained, "preliminary: found non-descendant" );
|
||||
assert.ok( jQuery.contains(container, element), "child" );
|
||||
assert.ok( jQuery.contains(container.parentNode, element), "grandchild" );
|
||||
assert.ok( jQuery.contains(container, text), "text child" );
|
||||
assert.ok( jQuery.contains(container.parentNode, text), "text grandchild" );
|
||||
assert.ok( !jQuery.contains(container, container), "self" );
|
||||
assert.ok( !jQuery.contains(element, container), "parent" );
|
||||
assert.ok( !jQuery.contains(container, nonContained), "non-descendant" );
|
||||
assert.ok( !jQuery.contains(container, document), "document" );
|
||||
assert.ok( !jQuery.contains(container, document.documentElement), "documentElement (negative)" );
|
||||
assert.ok( !jQuery.contains(container, null), "Passing null does not throw an error" );
|
||||
assert.ok( jQuery.contains(document, document.documentElement), "documentElement (positive)" );
|
||||
assert.ok( jQuery.contains(document, element), "document container (positive)" );
|
||||
assert.ok( !jQuery.contains(document, detached), "document container (negative)" );
|
||||
});
|
||||
assert.ok( jQuery.contains( container, element ), "child" );
|
||||
assert.ok( jQuery.contains( container.parentNode, element ), "grandchild" );
|
||||
assert.ok( jQuery.contains( container, text ), "text child" );
|
||||
assert.ok( jQuery.contains( container.parentNode, text ), "text grandchild" );
|
||||
assert.ok( !jQuery.contains( container, container ), "self" );
|
||||
assert.ok( !jQuery.contains( element, container ), "parent" );
|
||||
assert.ok( !jQuery.contains( container, nonContained ), "non-descendant" );
|
||||
assert.ok( !jQuery.contains( container, document ), "document" );
|
||||
assert.ok( !jQuery.contains( container, document.documentElement ), "documentElement (negative)" );
|
||||
assert.ok( !jQuery.contains( container, null ), "Passing null does not throw an error" );
|
||||
assert.ok( jQuery.contains( document, document.documentElement ), "documentElement (positive)" );
|
||||
assert.ok( jQuery.contains( document, element ), "document container (positive)" );
|
||||
assert.ok( !jQuery.contains( document, detached ), "document container (negative)" );
|
||||
} );
|
||||
|
||||
QUnit.test("jQuery.uniqueSort", function( assert ) {
|
||||
QUnit.test( "jQuery.uniqueSort", function( assert ) {
|
||||
assert.expect( 15 );
|
||||
|
||||
function Arrayish( arr ) {
|
||||
@@ -408,16 +408,16 @@ QUnit.test("jQuery.uniqueSort", function( assert ) {
|
||||
var i, tests,
|
||||
detached = [],
|
||||
body = document.body,
|
||||
fixture = document.getElementById("qunit-fixture"),
|
||||
detached1 = document.createElement("p"),
|
||||
detached2 = document.createElement("ul"),
|
||||
detachedChild = detached1.appendChild( document.createElement("a") ),
|
||||
detachedGrandchild = detachedChild.appendChild( document.createElement("b") );
|
||||
fixture = document.getElementById( "qunit-fixture" ),
|
||||
detached1 = document.createElement( "p" ),
|
||||
detached2 = document.createElement( "ul" ),
|
||||
detachedChild = detached1.appendChild( document.createElement( "a" ) ),
|
||||
detachedGrandchild = detachedChild.appendChild( document.createElement( "b" ) );
|
||||
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
detached.push( document.createElement("li") );
|
||||
detached[i].id = "detached" + i;
|
||||
detached2.appendChild( document.createElement("li") ).id = "detachedChild" + i;
|
||||
detached.push( document.createElement( "li" ) );
|
||||
detached[ i ].id = "detached" + i;
|
||||
detached2.appendChild( document.createElement( "li" ) ).id = "detachedChild" + i;
|
||||
}
|
||||
|
||||
tests = {
|
||||
@@ -443,16 +443,16 @@ QUnit.test("jQuery.uniqueSort", function( assert ) {
|
||||
},
|
||||
"Detached children": {
|
||||
input: [
|
||||
detached2.childNodes[0],
|
||||
detached2.childNodes[1],
|
||||
detached2.childNodes[2],
|
||||
detached2.childNodes[3]
|
||||
detached2.childNodes[ 0 ],
|
||||
detached2.childNodes[ 1 ],
|
||||
detached2.childNodes[ 2 ],
|
||||
detached2.childNodes[ 3 ]
|
||||
],
|
||||
expected: [
|
||||
detached2.childNodes[0],
|
||||
detached2.childNodes[1],
|
||||
detached2.childNodes[2],
|
||||
detached2.childNodes[3]
|
||||
detached2.childNodes[ 0 ],
|
||||
detached2.childNodes[ 1 ],
|
||||
detached2.childNodes[ 2 ],
|
||||
detached2.childNodes[ 3 ]
|
||||
]
|
||||
},
|
||||
"Attached/detached mixture": {
|
||||
@@ -465,23 +465,23 @@ QUnit.test("jQuery.uniqueSort", function( assert ) {
|
||||
jQuery.each( tests, function( label, test ) {
|
||||
var length = test.length || test.input.length;
|
||||
assert.deepEqual( jQuery.uniqueSort( test.input ).slice( 0, length ), test.expected, label + " (array)" );
|
||||
assert.deepEqual( jQuery.uniqueSort( new Arrayish(test.input) ).slice( 0, length ), test.expected, label + " (quasi-array)" );
|
||||
});
|
||||
assert.deepEqual( jQuery.uniqueSort( new Arrayish( test.input ) ).slice( 0, length ), test.expected, label + " (quasi-array)" );
|
||||
} );
|
||||
|
||||
assert.strictEqual( jQuery.unique, jQuery.uniqueSort, "jQuery.unique() is an alias for jQuery.uniqueSort()" );
|
||||
});
|
||||
} );
|
||||
|
||||
testIframe(
|
||||
"selector/sizzle_cache",
|
||||
"Sizzle cache collides with multiple Sizzles on a page",
|
||||
function( jQuery, window, document, assert ) {
|
||||
var $cached = window["$cached"];
|
||||
var $cached = window[ "$cached" ];
|
||||
|
||||
assert.expect(4);
|
||||
assert.expect( 4 );
|
||||
assert.notStrictEqual( jQuery, $cached, "Loaded two engines" );
|
||||
assert.deepEqual( $cached(".test a").get(), [ document.getElementById("collision") ], "Select collision anchor with first sizzle" );
|
||||
assert.equal( jQuery(".evil a").length, 0, "Select nothing with second sizzle" );
|
||||
assert.equal( jQuery(".evil a").length, 0, "Select nothing again with second sizzle" );
|
||||
assert.deepEqual( $cached( ".test a" ).get(), [ document.getElementById( "collision" ) ], "Select collision anchor with first sizzle" );
|
||||
assert.equal( jQuery( ".evil a" ).length, 0, "Select nothing with second sizzle" );
|
||||
assert.equal( jQuery( ".evil a" ).length, 0, "Select nothing again with second sizzle" );
|
||||
}
|
||||
);
|
||||
|
||||
@@ -512,9 +512,9 @@ QUnit.asyncTest( "Iframe dispatch should not affect jQuery (#13936)", 1, functio
|
||||
loaded = true;
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
iframeDoc.open();
|
||||
iframeDoc.write( "<body><form id='navigate' action='?'></form></body>" );
|
||||
iframeDoc.close();
|
||||
});
|
||||
} );
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
QUnit.module("serialize", { teardown: moduleTeardown });
|
||||
QUnit.module( "serialize", { teardown: moduleTeardown } );
|
||||
|
||||
QUnit.test("jQuery.param()", function( assert ) {
|
||||
assert.expect(22);
|
||||
QUnit.test( "jQuery.param()", function( assert ) {
|
||||
assert.expect( 22 );
|
||||
|
||||
var params, settings;
|
||||
|
||||
assert.equal( !( jQuery.ajaxSettings && jQuery.ajaxSettings.traditional ), true, "traditional flag, falsy by default" );
|
||||
|
||||
params = {"foo":"bar", "baz":42, "quux":"All your base are belong to us"};
|
||||
assert.equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
||||
params = { "foo":"bar", "baz":42, "quux":"All your base are belong to us" };
|
||||
assert.equal( jQuery.param( params ), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
||||
|
||||
params = {"string":"foo","null":null,"undefined":undefined};
|
||||
assert.equal( jQuery.param(params), "string=foo&null=&undefined=", "handle nulls and undefineds properly" );
|
||||
params = { "string":"foo","null":null,"undefined":undefined };
|
||||
assert.equal( jQuery.param( params ), "string=foo&null=&undefined=", "handle nulls and undefineds properly" );
|
||||
|
||||
params = {"someName": [1, 2, 3], "regularThing": "blah" };
|
||||
assert.equal( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" );
|
||||
params = { "someName": [ 1, 2, 3 ], "regularThing": "blah" };
|
||||
assert.equal( jQuery.param( params ), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" );
|
||||
|
||||
params = {"foo": ["a", "b", "c"]};
|
||||
assert.equal( jQuery.param(params), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" );
|
||||
params = { "foo": [ "a", "b", "c" ] };
|
||||
assert.equal( jQuery.param( params ), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" );
|
||||
|
||||
params = {"foo": ["baz", 42, "All your base are belong to us"] };
|
||||
assert.equal( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
||||
params = { "foo": [ "baz", 42, "All your base are belong to us" ] };
|
||||
assert.equal( jQuery.param( params ), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
||||
|
||||
params = {"foo": { "bar": "baz", "beep": 42, "quux": "All your base are belong to us" } };
|
||||
assert.equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
||||
params = { "foo": { "bar": "baz", "beep": 42, "quux": "All your base are belong to us" } };
|
||||
assert.equal( jQuery.param( params ), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
||||
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
assert.equal( decodeURIComponent( jQuery.param(params) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure" );
|
||||
params = { a:[ 1,2 ], b:{ c:3, d:[ 4,5 ], e:{ x:[ 6 ], y:7, z:[ 8,9 ] }, f:true, g:false, h:undefined }, i:[ 10,11 ], j:true, k:false, l:[ undefined,0 ], m:"cowboy hat?" };
|
||||
assert.equal( decodeURIComponent( jQuery.param( params ) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure" );
|
||||
|
||||
params = { "a": [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { "b": [ 7, [ 8, 9 ], [ { "c": 10, "d": 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { "e": { "f": { "g": [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
|
||||
assert.equal( decodeURIComponent( jQuery.param(params) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" );
|
||||
assert.equal( decodeURIComponent( jQuery.param( params ) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" );
|
||||
|
||||
params = { "a":[1,2], "b":{ "c":3, "d":[4,5], "e":{ "x":[6], "y":7, "z":[8,9] }, "f":true, "g":false, "h":undefined }, "i":[10,11], "j":true, "k":false, "l":[undefined,0], "m":"cowboy hat?" };
|
||||
assert.equal( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
|
||||
params = { "a":[ 1,2 ], "b":{ "c":3, "d":[ 4,5 ], "e":{ "x":[ 6 ], "y":7, "z":[ 8,9 ] }, "f":true, "g":false, "h":undefined }, "i":[ 10,11 ], "j":true, "k":false, "l":[ undefined,0 ], "m":"cowboy hat?" };
|
||||
assert.equal( jQuery.param( params, true ), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
|
||||
|
||||
assert.equal( decodeURIComponent( jQuery.param({ "a": [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], "e": { "f": [10], "g": [11,12], "h": 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
|
||||
assert.equal( decodeURIComponent( jQuery.param( { "a": [ 1,2,3 ], "b[]": [ 4,5,6 ], "c[d]": [ 7,8,9 ], "e": { "f": [ 10 ], "g": [ 11,12 ], "h": 13 } } ) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
|
||||
|
||||
// #7945
|
||||
assert.equal( jQuery.param({"jquery": "1.4.2"}), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" );
|
||||
assert.equal( jQuery.param( { "jquery": "1.4.2" } ), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" );
|
||||
|
||||
settings = { traditional: true };
|
||||
|
||||
@@ -47,58 +47,58 @@ QUnit.test("jQuery.param()", function( assert ) {
|
||||
jQuery.ajaxSettings = settings;
|
||||
}
|
||||
|
||||
params = {"foo":"bar", "baz":42, "quux":"All your base are belong to us"};
|
||||
assert.equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
||||
params = { "foo":"bar", "baz":42, "quux":"All your base are belong to us" };
|
||||
assert.equal( jQuery.param( params ), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
||||
|
||||
params = {"someName": [1, 2, 3], "regularThing": "blah" };
|
||||
assert.equal( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
|
||||
params = { "someName": [ 1, 2, 3 ], "regularThing": "blah" };
|
||||
assert.equal( jQuery.param( params ), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
|
||||
|
||||
params = {"foo": ["a", "b", "c"]};
|
||||
assert.equal( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" );
|
||||
params = { "foo": [ "a", "b", "c" ] };
|
||||
assert.equal( jQuery.param( params ), "foo=a&foo=b&foo=c", "with array of strings" );
|
||||
|
||||
params = {"foo[]":["baz", 42, "All your base are belong to us"]};
|
||||
assert.equal( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
||||
params = { "foo[]":[ "baz", 42, "All your base are belong to us" ] };
|
||||
assert.equal( jQuery.param( params ), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
||||
|
||||
params = {"foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us"};
|
||||
assert.equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
||||
params = { "foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us" };
|
||||
assert.equal( jQuery.param( params ), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
||||
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
assert.equal( jQuery.param(params), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure" );
|
||||
params = { a:[ 1,2 ], b:{ c:3, d:[ 4,5 ], e:{ x:[ 6 ], y:7, z:[ 8,9 ] }, f:true, g:false, h:undefined }, i:[ 10,11 ], j:true, k:false, l:[ undefined,0 ], m:"cowboy hat?" };
|
||||
assert.equal( jQuery.param( params ), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure" );
|
||||
|
||||
params = { "a": [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { "b": [ 7, [ 8, 9 ], [ { "c": 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { "e": { "f": { "g": [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
|
||||
assert.equal( jQuery.param(params), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" );
|
||||
assert.equal( jQuery.param( params ), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" );
|
||||
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
assert.equal( decodeURIComponent( jQuery.param(params,false) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" );
|
||||
params = { a:[ 1,2 ], b:{ c:3, d:[ 4,5 ], e:{ x:[ 6 ], y:7, z:[ 8,9 ] }, f:true, g:false, h:undefined }, i:[ 10,11 ], j:true, k:false, l:[ undefined,0 ], m:"cowboy hat?" };
|
||||
assert.equal( decodeURIComponent( jQuery.param( params, false ) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" );
|
||||
|
||||
params = { "param1": null };
|
||||
assert.equal( jQuery.param(params,false), "param1=", "Make sure that null params aren't traversed." );
|
||||
assert.equal( jQuery.param( params, false ), "param1=", "Make sure that null params aren't traversed." );
|
||||
|
||||
params = {"test": {"length": 3, "foo": "bar"} };
|
||||
params = { "test": { "length": 3, "foo": "bar" } };
|
||||
assert.equal( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" );
|
||||
|
||||
if ( jQuery.ajaxSettings === settings ) {
|
||||
delete jQuery.ajaxSettings;
|
||||
} else {
|
||||
jQuery.ajaxSetup({ traditional: false });
|
||||
jQuery.ajaxSetup( { traditional: false } );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test("jQuery.param() Constructed prop values", function( assert ) {
|
||||
QUnit.test( "jQuery.param() Constructed prop values", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
/** @constructor */
|
||||
function Record() {
|
||||
this["prop"] = "val";
|
||||
this[ "prop" ] = "val";
|
||||
}
|
||||
|
||||
var MyString = String,
|
||||
MyNumber = Number,
|
||||
params = { "test": new MyString("foo") };
|
||||
params = { "test": new MyString( "foo" ) };
|
||||
|
||||
assert.equal( jQuery.param( params, false ), "test=foo", "Do not mistake new String() for a plain object" );
|
||||
|
||||
params = { "test": new MyNumber(5) };
|
||||
params = { "test": new MyNumber( 5 ) };
|
||||
assert.equal( jQuery.param( params, false ), "test=5", "Do not mistake new Number() for a plain object" );
|
||||
|
||||
params = { "test": new Date() };
|
||||
@@ -106,41 +106,41 @@ QUnit.test("jQuery.param() Constructed prop values", function( assert ) {
|
||||
|
||||
// should allow non-native constructed objects
|
||||
params = { "test": new Record() };
|
||||
assert.equal( jQuery.param( params, false ), jQuery.param({ "test": { "prop": "val" } }), "Allow non-native constructed objects" );
|
||||
});
|
||||
assert.equal( jQuery.param( params, false ), jQuery.param( { "test": { "prop": "val" } } ), "Allow non-native constructed objects" );
|
||||
} );
|
||||
|
||||
QUnit.test("serialize()", function( assert ) {
|
||||
assert.expect(6);
|
||||
QUnit.test( "serialize()", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
// Add html5 elements only for serialize because selector can't yet find them on non-html5 browsers
|
||||
jQuery("#search").after(
|
||||
jQuery( "#search" ).after(
|
||||
"<input type='email' id='html5email' name='email' value='dave@jquery.com' />" +
|
||||
"<input type='number' id='html5number' name='number' value='43' />" +
|
||||
"<input type='file' name='fileupload' />"
|
||||
);
|
||||
|
||||
assert.equal( jQuery("#form").serialize(),
|
||||
assert.equal( jQuery( "#form" ).serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3",
|
||||
"Check form serialization as query string");
|
||||
"Check form serialization as query string" );
|
||||
|
||||
assert.equal( jQuery("input,select,textarea,button", "#form").serialize(),
|
||||
assert.equal( jQuery( "input,select,textarea,button", "#form" ).serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3",
|
||||
"Check input serialization as query string");
|
||||
"Check input serialization as query string" );
|
||||
|
||||
assert.equal( jQuery("#testForm").serialize(),
|
||||
assert.equal( jQuery( "#testForm" ).serialize(),
|
||||
"T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
"Check form serialization as query string");
|
||||
"Check form serialization as query string" );
|
||||
|
||||
assert.equal( jQuery("input,select,textarea,button", "#testForm").serialize(),
|
||||
assert.equal( jQuery( "input,select,textarea,button", "#testForm" ).serialize(),
|
||||
"T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
"Check input serialization as query string");
|
||||
"Check input serialization as query string" );
|
||||
|
||||
assert.equal( jQuery("#form, #testForm").serialize(),
|
||||
assert.equal( jQuery( "#form, #testForm" ).serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
"Multiple form serialization as query string");
|
||||
"Multiple form serialization as query string" );
|
||||
|
||||
assert.equal( jQuery("#form, #testForm :input").serialize(),
|
||||
assert.equal( jQuery( "#form, #testForm :input" ).serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
"Mixed form/input serialization as query string");
|
||||
jQuery("#html5email, #html5number").remove();
|
||||
});
|
||||
"Mixed form/input serialization as query string" );
|
||||
jQuery( "#html5email, #html5number" ).remove();
|
||||
} );
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
QUnit.module("support", { teardown: moduleTeardown });
|
||||
QUnit.module( "support", { teardown: moduleTeardown } );
|
||||
|
||||
var computedSupport = getComputedSupport( jQuery.support );
|
||||
|
||||
@@ -45,14 +45,14 @@ testIframeWithCallback(
|
||||
|
||||
QUnit.stop();
|
||||
|
||||
supportjQuery.get( "data/support/csp.log" ).done(function( data ) {
|
||||
supportjQuery.get( "data/support/csp.log" ).done( function( data ) {
|
||||
assert.equal( data, "", "No log request should be sent" );
|
||||
supportjQuery.get( "data/support/csp-clean.php" ).done( start );
|
||||
});
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
(function() {
|
||||
( function() {
|
||||
var expected,
|
||||
userAgent = window.navigator.userAgent;
|
||||
|
||||
@@ -111,6 +111,7 @@ testIframeWithCallback(
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /chrome/i.test( userAgent ) ) {
|
||||
|
||||
// Catches Chrome on Android as well (i.e. the default
|
||||
// Android browser on Android >= 4.4).
|
||||
expected = {
|
||||
@@ -270,16 +271,17 @@ testIframeWithCallback(
|
||||
assert.expect( j );
|
||||
|
||||
for ( i in expected ) {
|
||||
|
||||
// TODO check for all modules containing support properties
|
||||
if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
|
||||
assert.equal( computedSupport[ i ], expected[ i ],
|
||||
"jQuery.support['" + i + "']: " + computedSupport[ i ] +
|
||||
", expected['" + i + "']: " + expected[ i ]);
|
||||
", expected['" + i + "']: " + expected[ i ] );
|
||||
} else {
|
||||
assert.ok( true, "no ajax; skipping jQuery.support[' " + i + " ']" );
|
||||
}
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
})();
|
||||
} )();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
(function() {
|
||||
( function() {
|
||||
|
||||
if ( !jQuery.fn.wrap ) { // no wrap module
|
||||
return;
|
||||
@@ -6,7 +6,7 @@ if ( !jQuery.fn.wrap ) { // no wrap module
|
||||
|
||||
QUnit.module( "wrap", {
|
||||
teardown: moduleTeardown
|
||||
});
|
||||
} );
|
||||
|
||||
// See test/unit/manipulation.js for explanation about these 2 functions
|
||||
function manipulationBareObj( value ) {
|
||||
@@ -19,36 +19,54 @@ function manipulationFunctionReturningObj( value ) {
|
||||
};
|
||||
}
|
||||
|
||||
function testWrap( val , assert ) {
|
||||
function testWrap( val, assert ) {
|
||||
|
||||
assert.expect( 19 );
|
||||
|
||||
var defaultText, result, j, i, cacheLength;
|
||||
|
||||
defaultText = "Try them out:";
|
||||
result = jQuery("#first").wrap( val("<div class='red'><span></span></div>") ).text();
|
||||
result = jQuery( "#first" ).wrap( val( "<div class='red'><span></span></div>" ) ).text();
|
||||
|
||||
assert.equal( defaultText, result, "Check for wrapping of on-the-fly html" );
|
||||
assert.ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
assert.equal(
|
||||
defaultText, result, "Check for wrapping of on-the-fly html"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'"
|
||||
);
|
||||
|
||||
result = jQuery("#first").wrap( val(document.getElementById("empty")) ).parent();
|
||||
assert.ok( result.is("ol"), "Check for element wrapping" );
|
||||
assert.equal( result.text(), defaultText, "Check for element wrapping" );
|
||||
result = jQuery( "#first" ).wrap( val( document.getElementById( "empty" ) ) ).parent();
|
||||
assert.ok(
|
||||
result.is( "ol" ), "Check for element wrapping"
|
||||
);
|
||||
assert.equal(
|
||||
result.text(), defaultText, "Check for element wrapping"
|
||||
);
|
||||
|
||||
jQuery("#check1").on( "click", function() {
|
||||
jQuery( "#check1" ).on( "click", function() {
|
||||
var checkbox = this;
|
||||
|
||||
assert.ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
||||
jQuery( checkbox ).wrap( val("<div id='c1' style='display:none;'></div>") );
|
||||
assert.ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
||||
}).prop( "checked", false )[ 0 ].click();
|
||||
assert.ok(
|
||||
checkbox.checked, "Checkbox's state is erased after wrap() action, see #769"
|
||||
);
|
||||
jQuery( checkbox ).wrap( val( "<div id='c1' style='display:none;'></div>" ) );
|
||||
assert.ok(
|
||||
checkbox.checked, "Checkbox's state is erased after wrap() action, see #769"
|
||||
);
|
||||
} ).prop( "checked", false )[ 0 ].click();
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
j = jQuery("#nonnodes").contents();
|
||||
j.wrap( val("<i></i>") );
|
||||
j = jQuery( "#nonnodes" ).contents();
|
||||
j.wrap( val( "<i></i>" ) );
|
||||
|
||||
assert.equal( jQuery("#nonnodes > i").length, jQuery("#nonnodes")[ 0 ].childNodes.length, "Check node,textnode,comment wraps ok" );
|
||||
assert.equal( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" );
|
||||
assert.equal(
|
||||
jQuery( "#nonnodes > i" ).length, jQuery( "#nonnodes" )[ 0 ].childNodes.length,
|
||||
"Check node,textnode,comment wraps ok"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#nonnodes > i" ).text(), j.text(),
|
||||
"Check node,textnode,comment wraps doesn't hurt text"
|
||||
);
|
||||
|
||||
// Try wrapping a disconnected node
|
||||
cacheLength = 0;
|
||||
@@ -56,79 +74,109 @@ function testWrap( val , assert ) {
|
||||
cacheLength++;
|
||||
}
|
||||
|
||||
j = jQuery("<label/>").wrap( val("<li/>") );
|
||||
assert.equal( j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label" );
|
||||
assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
|
||||
j = jQuery( "<label/>" ).wrap( val( "<li/>" ) );
|
||||
assert.equal(
|
||||
j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label"
|
||||
);
|
||||
assert.equal(
|
||||
j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped"
|
||||
);
|
||||
|
||||
for ( i in jQuery.cache ) {
|
||||
cacheLength--;
|
||||
}
|
||||
assert.equal( cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)" );
|
||||
assert.equal(
|
||||
cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)"
|
||||
);
|
||||
|
||||
// Wrap an element containing a text node
|
||||
j = jQuery("<span/>").wrap("<div>test</div>");
|
||||
assert.equal( j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element" );
|
||||
assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element." );
|
||||
j = jQuery( "<span/>" ).wrap( "<div>test</div>" );
|
||||
assert.equal(
|
||||
j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element"
|
||||
);
|
||||
assert.equal(
|
||||
j[ 0 ].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element."
|
||||
);
|
||||
|
||||
// Try to wrap an element with multiple elements (should fail)
|
||||
j = jQuery("<div><span></span></div>").children().wrap("<p></p><div></div>");
|
||||
assert.equal( j[ 0 ].parentNode.parentNode.childNodes.length, 1, "There should only be one element wrapping." );
|
||||
assert.equal( j.length, 1, "There should only be one element (no cloning)." );
|
||||
assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph." );
|
||||
j = jQuery( "<div><span></span></div>" ).children().wrap( "<p></p><div></div>" );
|
||||
assert.equal(
|
||||
j[ 0 ].parentNode.parentNode.childNodes.length, 1,
|
||||
"There should only be one element wrapping."
|
||||
);
|
||||
assert.equal(
|
||||
j.length, 1, "There should only be one element (no cloning)."
|
||||
);
|
||||
assert.equal(
|
||||
j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph."
|
||||
);
|
||||
|
||||
// Wrap an element with a jQuery set
|
||||
j = jQuery("<span/>").wrap( jQuery("<div></div>") );
|
||||
assert.equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
|
||||
j = jQuery( "<span/>" ).wrap( jQuery( "<div></div>" ) );
|
||||
assert.equal(
|
||||
j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works."
|
||||
);
|
||||
|
||||
// Wrap an element with a jQuery set and event
|
||||
result = jQuery("<div></div>").on( "click", function() {
|
||||
assert.ok( true, "Event triggered." );
|
||||
result = jQuery( "<div></div>" ).on( "click", function() {
|
||||
assert.ok(
|
||||
true, "Event triggered."
|
||||
);
|
||||
|
||||
// Remove handlers on detached elements
|
||||
result.off();
|
||||
jQuery(this).off();
|
||||
});
|
||||
jQuery( this ).off();
|
||||
} );
|
||||
|
||||
j = jQuery("<span/>").wrap( result );
|
||||
assert.equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
|
||||
j = jQuery( "<span/>" ).wrap( result );
|
||||
assert.equal(
|
||||
j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works."
|
||||
);
|
||||
|
||||
j.parent().trigger("click");
|
||||
j.parent().trigger( "click" );
|
||||
}
|
||||
|
||||
QUnit.test( "wrap(String|Element)", function( assert ) {
|
||||
testWrap( manipulationBareObj, assert );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "wrap(Function)", function( assert ) {
|
||||
testWrap( manipulationFunctionReturningObj, assert );
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "wrap(Function) with index (#10177)", function( assert ) {
|
||||
var expectedIndex = 0,
|
||||
targets = jQuery("#qunit-fixture p");
|
||||
targets = jQuery( "#qunit-fixture p" );
|
||||
|
||||
assert.expect( targets.length );
|
||||
targets.wrap(function(i) {
|
||||
assert.equal( i, expectedIndex, "Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")" );
|
||||
targets.wrap( function( i ) {
|
||||
assert.equal(
|
||||
i, expectedIndex,
|
||||
"Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")"
|
||||
);
|
||||
expectedIndex++;
|
||||
|
||||
return "<div id='wrap_index_'" + i + "'></div>";
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "wrap(String) consecutive elements (#10177)", function( assert ) {
|
||||
var targets = jQuery("#qunit-fixture p");
|
||||
var targets = jQuery( "#qunit-fixture p" );
|
||||
|
||||
assert.expect( targets.length * 2 );
|
||||
targets.wrap("<div class='wrapper'></div>");
|
||||
targets.wrap( "<div class='wrapper'></div>" );
|
||||
|
||||
targets.each(function() {
|
||||
var $this = jQuery(this);
|
||||
targets.each( function() {
|
||||
var $this = jQuery( this );
|
||||
|
||||
assert.ok( $this.parent().is(".wrapper"), "Check each elements parent is correct (.wrapper)" );
|
||||
assert.equal( $this.siblings().length, 0, "Each element should be wrapped individually" );
|
||||
});
|
||||
});
|
||||
assert.ok(
|
||||
$this.parent().is( ".wrapper" ), "Check each elements parent is correct (.wrapper)"
|
||||
);
|
||||
assert.equal(
|
||||
$this.siblings().length, 0, "Each element should be wrapped individually"
|
||||
);
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapAll(String)", function( assert ) {
|
||||
|
||||
@@ -136,65 +184,97 @@ QUnit.test( "wrapAll(String)", function( assert ) {
|
||||
|
||||
var prev, p, result;
|
||||
|
||||
prev = jQuery("#firstp")[ 0 ].previousSibling;
|
||||
p = jQuery("#firstp,#first")[ 0 ].parentNode;
|
||||
result = jQuery("#firstp,#first").wrapAll( "<div class='red'><div class='tmp'></div></div>" );
|
||||
prev = jQuery( "#firstp" )[ 0 ].previousSibling;
|
||||
p = jQuery( "#firstp,#first" )[ 0 ].parentNode;
|
||||
result = jQuery( "#firstp,#first" ).wrapAll( "<div class='red'><div class='tmp'></div></div>" );
|
||||
|
||||
assert.equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
||||
assert.ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
assert.ok( jQuery("#firstp").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
assert.equal( jQuery("#first").parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
assert.equal( jQuery("#first").parent().parent()[ 0 ].parentNode, p, "Correct Parent" );
|
||||
assert.equal(
|
||||
result.parent().length, 1, "Check for wrapping of on-the-fly html"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#first" ).parent().parent()[ 0 ].parentNode, p, "Correct Parent"
|
||||
);
|
||||
|
||||
});
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapAll(Function)", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var prev = jQuery( "#firstp" )[ 0 ].previousSibling,
|
||||
p = jQuery( "#firstp,#first" )[ 0 ].parentNode,
|
||||
result = jQuery( "#firstp,#first" ).wrapAll(function() {
|
||||
result = jQuery( "#firstp,#first" ).wrapAll( function() {
|
||||
return "<div class='red'><div class='tmp'></div></div>";
|
||||
});
|
||||
} );
|
||||
|
||||
assert.equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
||||
assert.ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
assert.ok( jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
assert.ok( jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent" );
|
||||
assert.strictEqual( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
});
|
||||
assert.equal(
|
||||
result.parent().length, 1, "Check for wrapping of on-the-fly html"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent"
|
||||
);
|
||||
assert.strictEqual(
|
||||
jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapAll(Function) check execution characteristics", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var i = 0;
|
||||
|
||||
jQuery( "non-existent" ).wrapAll(function() {
|
||||
jQuery( "non-existent" ).wrapAll( function() {
|
||||
i++;
|
||||
return "";
|
||||
});
|
||||
} );
|
||||
|
||||
assert.ok( !i, "should not execute function argument if target element does not exist" );
|
||||
assert.ok(
|
||||
!i, "should not execute function argument if target element does not exist"
|
||||
);
|
||||
|
||||
jQuery( "#firstp" ).wrapAll(function( index ) {
|
||||
assert.strictEqual( this, jQuery( "#firstp" )[ 0 ], "context must be the first found element" );
|
||||
assert.strictEqual( index, undefined, "index argument should not be included in function execution" );
|
||||
});
|
||||
});
|
||||
jQuery( "#firstp" ).wrapAll( function( index ) {
|
||||
assert.strictEqual(
|
||||
this, jQuery( "#firstp" )[ 0 ], "context must be the first found element"
|
||||
);
|
||||
assert.strictEqual(
|
||||
index, undefined, "index argument should not be included in function execution"
|
||||
);
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapAll(Element)", function( assert ) {
|
||||
|
||||
assert.expect( 3 );
|
||||
|
||||
var prev, p;
|
||||
prev = jQuery("#firstp")[ 0 ].previousSibling;
|
||||
p = jQuery("#first")[ 0 ].parentNode;
|
||||
jQuery("#firstp,#first").wrapAll( document.getElementById("empty") );
|
||||
prev = jQuery( "#firstp" )[ 0 ].previousSibling;
|
||||
p = jQuery( "#first" )[ 0 ].parentNode;
|
||||
jQuery( "#firstp,#first" ).wrapAll( document.getElementById( "empty" ) );
|
||||
|
||||
assert.equal( jQuery("#first").parent()[ 0 ], jQuery("#firstp").parent()[ 0 ], "Same Parent" );
|
||||
assert.equal( jQuery("#first").parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
assert.equal( jQuery("#first").parent()[ 0 ].parentNode, p, "Correct Parent" );
|
||||
});
|
||||
assert.equal(
|
||||
jQuery( "#first" ).parent()[ 0 ], jQuery( "#firstp" ).parent()[ 0 ], "Same Parent"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#first" ).parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#first" ).parent()[ 0 ].parentNode, p, "Correct Parent"
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapInner(String)", function( assert ) {
|
||||
|
||||
@@ -202,37 +282,59 @@ QUnit.test( "wrapInner(String)", function( assert ) {
|
||||
|
||||
var num;
|
||||
|
||||
num = jQuery("#first").children().length;
|
||||
jQuery("#first").wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
||||
num = jQuery( "#first" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
||||
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#first" ).children().is( ".red" ), "Verify Right Element"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
|
||||
num = jQuery("#first").html("foo<div>test</div><div>test2</div>").children().length;
|
||||
jQuery("#first").wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
});
|
||||
num = jQuery( "#first" ).html( "foo<div>test</div><div>test2</div>" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#first" ).children().is( ".red" ), "Verify Right Element"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapInner(Element)", function( assert ) {
|
||||
|
||||
assert.expect( 5 );
|
||||
|
||||
var num,
|
||||
div = jQuery("<div/>");
|
||||
div = jQuery( "<div/>" );
|
||||
|
||||
num = jQuery("#first").children().length;
|
||||
jQuery("#first").wrapInner( document.getElementById("empty") );
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
||||
num = jQuery( "#first" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( document.getElementById( "empty" ) );
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
|
||||
div.wrapInner( "<span></span>" );
|
||||
assert.equal( div.children().length, 1, "The contents were wrapped." );
|
||||
assert.equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
|
||||
});
|
||||
assert.equal(
|
||||
div.children().length, 1, "The contents were wrapped."
|
||||
);
|
||||
assert.equal(
|
||||
div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted."
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapInner(Function) returns String", function( assert ) {
|
||||
|
||||
@@ -241,19 +343,31 @@ QUnit.test( "wrapInner(Function) returns String", function( assert ) {
|
||||
var num,
|
||||
val = manipulationFunctionReturningObj;
|
||||
|
||||
num = jQuery("#first").children().length;
|
||||
jQuery("#first").wrapInner( val("<div class='red'><div id='tmp'></div></div>") );
|
||||
num = jQuery( "#first" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( val( "<div class='red'><div id='tmp'></div></div>" ) );
|
||||
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#first" ).children().is( ".red" ), "Verify Right Element"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
|
||||
num = jQuery("#first").html("foo<div>test</div><div>test2</div>").children().length;
|
||||
jQuery("#first").wrapInner( val("<div class='red'><div id='tmp'></div></div>") );
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
});
|
||||
num = jQuery( "#first" ).html( "foo<div>test</div><div>test2</div>" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( val( "<div class='red'><div id='tmp'></div></div>" ) );
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#first" ).children().is( ".red" ), "Verify Right Element"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapInner(Function) returns Element", function( assert ) {
|
||||
|
||||
@@ -261,71 +375,127 @@ QUnit.test( "wrapInner(Function) returns Element", function( assert ) {
|
||||
|
||||
var num,
|
||||
val = manipulationFunctionReturningObj,
|
||||
div = jQuery("<div/>");
|
||||
div = jQuery( "<div/>" );
|
||||
|
||||
num = jQuery("#first").children().length;
|
||||
jQuery("#first").wrapInner( val(document.getElementById("empty")) );
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
||||
num = jQuery( "#first" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( val( document.getElementById( "empty" ) ) );
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
assert.ok(
|
||||
jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery( "#first" ).children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
|
||||
div.wrapInner( val("<span></span>") );
|
||||
assert.equal( div.children().length, 1, "The contents were wrapped." );
|
||||
assert.equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
|
||||
});
|
||||
div.wrapInner( val( "<span></span>" ) );
|
||||
assert.equal(
|
||||
div.children().length, 1, "The contents were wrapped."
|
||||
);
|
||||
assert.equal(
|
||||
div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted."
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "unwrap()", function( assert ) {
|
||||
|
||||
assert.expect( 9 );
|
||||
|
||||
jQuery("body").append(" <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> <div id='unwrap3'> <b><span class='unwrap unwrap3'>e</span></b> <b><span class='unwrap unwrap3'>f</span></b> </div> </div>");
|
||||
jQuery( "body" ).append(
|
||||
" <div id='unwrap' style='display: none;'> <div id='unwrap1'>" +
|
||||
" <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'>" +
|
||||
" <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> <div id='unwrap3'>" +
|
||||
" <b><span class='unwrap unwrap3'>e</span></b>" +
|
||||
" <b><span class='unwrap unwrap3'>f</span></b> </div> </div>"
|
||||
);
|
||||
|
||||
var abcd = jQuery("#unwrap1 > span, #unwrap2 > span").get(),
|
||||
abcdef = jQuery("#unwrap span").get();
|
||||
var abcd = jQuery( "#unwrap1 > span, #unwrap2 > span" ).get(),
|
||||
abcdef = jQuery( "#unwrap span" ).get();
|
||||
|
||||
assert.equal( jQuery("#unwrap1 span").add("#unwrap2 span:first-child").unwrap().length, 3, "make #unwrap1 and #unwrap2 go away" );
|
||||
assert.deepEqual( jQuery("#unwrap > span").get(), abcd, "all four spans should still exist" );
|
||||
assert.equal(
|
||||
jQuery( "#unwrap1 span" ).add( "#unwrap2 span:first-child" ).unwrap().length, 3,
|
||||
"make #unwrap1 and #unwrap2 go away"
|
||||
);
|
||||
assert.deepEqual(
|
||||
jQuery( "#unwrap > span" ).get(), abcd, "all four spans should still exist"
|
||||
);
|
||||
|
||||
assert.deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap3 > span").get(), "make all b in #unwrap3 go away" );
|
||||
assert.deepEqual(
|
||||
jQuery( "#unwrap3 span" ).unwrap().get(), jQuery( "#unwrap3 > span" ).get(),
|
||||
"make all b in #unwrap3 go away"
|
||||
);
|
||||
|
||||
assert.deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap > span.unwrap3").get(), "make #unwrap3 go away" );
|
||||
assert.deepEqual(
|
||||
jQuery( "#unwrap3 span" ).unwrap().get(), jQuery( "#unwrap > span.unwrap3" ).get(),
|
||||
"make #unwrap3 go away"
|
||||
);
|
||||
|
||||
assert.deepEqual( jQuery("#unwrap").children().get(), abcdef, "#unwrap only contains 6 child spans" );
|
||||
assert.deepEqual(
|
||||
jQuery( "#unwrap" ).children().get(), abcdef, "#unwrap only contains 6 child spans"
|
||||
);
|
||||
|
||||
assert.deepEqual( jQuery("#unwrap > span").unwrap().get(), jQuery("body > span.unwrap").get(), "make the 6 spans become children of body" );
|
||||
assert.deepEqual(
|
||||
jQuery( "#unwrap > span" ).unwrap().get(), jQuery( "body > span.unwrap" ).get(),
|
||||
"make the 6 spans become children of body"
|
||||
);
|
||||
|
||||
assert.deepEqual( jQuery("body > span.unwrap").unwrap().get(), jQuery("body > span.unwrap").get(), "can't unwrap children of body" );
|
||||
assert.deepEqual( jQuery("body > span.unwrap").unwrap().get(), abcdef, "can't unwrap children of body" );
|
||||
assert.deepEqual(
|
||||
jQuery( "body > span.unwrap" ).unwrap().get(), jQuery( "body > span.unwrap" ).get(),
|
||||
"can't unwrap children of body"
|
||||
);
|
||||
assert.deepEqual(
|
||||
jQuery( "body > span.unwrap" ).unwrap().get(), abcdef, "can't unwrap children of body"
|
||||
);
|
||||
|
||||
assert.deepEqual( jQuery("body > span.unwrap").get(), abcdef, "body contains 6 .unwrap child spans" );
|
||||
assert.deepEqual(
|
||||
jQuery( "body > span.unwrap" ).get(), abcdef, "body contains 6 .unwrap child spans"
|
||||
);
|
||||
|
||||
jQuery("body > span.unwrap").remove();
|
||||
});
|
||||
jQuery( "body > span.unwrap" ).remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "unwrap( selector )", function( assert ) {
|
||||
|
||||
assert.expect( 5 );
|
||||
|
||||
jQuery( "body" ).append( " <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> </div>" );
|
||||
jQuery( "body" ).append(
|
||||
" <div id='unwrap' style='display: none;'> <div id='unwrap1'>" +
|
||||
"<span class='unwrap'>a</span> <span class='unwrap'>b</span> </div>" +
|
||||
" <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span>" +
|
||||
" </div> </div>"
|
||||
);
|
||||
|
||||
// Shouldn't unwrap, no match
|
||||
jQuery( "#unwrap1 span" ) .unwrap( "#unwrap2" );
|
||||
assert.equal( jQuery("#unwrap1").length, 1, "still wrapped" );
|
||||
assert.equal(
|
||||
jQuery( "#unwrap1" ).length, 1, "still wrapped"
|
||||
);
|
||||
|
||||
// Shouldn't unwrap, no match
|
||||
jQuery( "#unwrap1 span" ) .unwrap( "span" );
|
||||
assert.equal( jQuery("#unwrap1").length, 1, "still wrapped" );
|
||||
assert.equal(
|
||||
jQuery( "#unwrap1" ).length, 1, "still wrapped"
|
||||
);
|
||||
|
||||
// Unwraps
|
||||
jQuery( "#unwrap1 span" ) .unwrap( "#unwrap1" );
|
||||
assert.equal( jQuery("#unwrap1").length, 0, "unwrapped match" );
|
||||
assert.equal(
|
||||
jQuery( "#unwrap1" ).length, 0, "unwrapped match"
|
||||
);
|
||||
|
||||
// Check return values
|
||||
assert.deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "quote" ).get(), "return on unmatched unwrap" );
|
||||
assert.deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "#unwrap2" ).get(), "return on matched unwrap" );
|
||||
assert.deepEqual(
|
||||
jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "quote" ).get(),
|
||||
"return on unmatched unwrap"
|
||||
);
|
||||
assert.deepEqual(
|
||||
jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "#unwrap2" ).get(),
|
||||
"return on matched unwrap"
|
||||
);
|
||||
|
||||
jQuery("body > span.unwrap").remove();
|
||||
});
|
||||
jQuery( "body > span.unwrap" ).remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", function( assert ) {
|
||||
|
||||
@@ -334,24 +504,33 @@ QUnit.test( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", f
|
||||
var $wraptarget = jQuery( "<div id='wrap-target'>Target</div>" ).appendTo( "#qunit-fixture" ),
|
||||
$section = jQuery( "<section>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
$wraptarget.wrapAll("<aside style='background-color:green'></aside>");
|
||||
$wraptarget.wrapAll( "<aside style='background-color:green'></aside>" );
|
||||
|
||||
assert.notEqual( $wraptarget.parent("aside").get( 0 ).style.backgroundColor, "transparent", "HTML5 elements created with wrapAll inherit styles" );
|
||||
assert.notEqual( $section.get( 0 ).style.backgroundColor, "transparent", "HTML5 elements create with jQuery( string ) inherit styles" );
|
||||
});
|
||||
assert.notEqual(
|
||||
$wraptarget.parent( "aside" ).get( 0 ).style.backgroundColor, "transparent",
|
||||
"HTML5 elements created with wrapAll inherit styles"
|
||||
);
|
||||
assert.notEqual(
|
||||
$section.get( 0 ).style.backgroundColor, "transparent",
|
||||
"HTML5 elements create with jQuery( string ) inherit styles"
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapping scripts (#10470)", function( assert ) {
|
||||
|
||||
assert.expect( 2 );
|
||||
|
||||
var script = document.createElement("script");
|
||||
script.text = script.textContent = "ok( !document.eval10470, 'script evaluated once' ); document.eval10470 = true;";
|
||||
var script = document.createElement( "script" );
|
||||
script.text = script.textContent =
|
||||
"ok( !document.eval10470, 'script evaluated once' ); document.eval10470 = true;";
|
||||
|
||||
document.eval10470 = false;
|
||||
jQuery("#qunit-fixture").empty()[0].appendChild( script );
|
||||
jQuery("#qunit-fixture script").wrap("<b></b>");
|
||||
assert.strictEqual( script.parentNode, jQuery("#qunit-fixture > b")[ 0 ], "correctly wrapped" );
|
||||
jQuery( "#qunit-fixture" ).empty()[ 0 ].appendChild( script );
|
||||
jQuery( "#qunit-fixture script" ).wrap( "<b></b>" );
|
||||
assert.strictEqual(
|
||||
script.parentNode, jQuery( "#qunit-fixture > b" )[ 0 ], "correctly wrapped"
|
||||
);
|
||||
jQuery( script ).remove();
|
||||
});
|
||||
} );
|
||||
|
||||
})();
|
||||
} )();
|
||||
|
||||
Reference in New Issue
Block a user