mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
merge from dev
This commit is contained in:
parent
d96250df7f
commit
bcfee41a57
318 changed files with 54424 additions and 6419 deletions
2412
dashboard-ui/bower_components/jquery/test/unit/ajax.js
vendored
Normal file
2412
dashboard-ui/bower_components/jquery/test/unit/ajax.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
1522
dashboard-ui/bower_components/jquery/test/unit/attributes.js
vendored
Normal file
1522
dashboard-ui/bower_components/jquery/test/unit/attributes.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
302
dashboard-ui/bower_components/jquery/test/unit/basic.js
vendored
Normal file
302
dashboard-ui/bower_components/jquery/test/unit/basic.js
vendored
Normal file
|
@ -0,0 +1,302 @@
|
|||
QUnit.module( "basic", { teardown: moduleTeardown } );
|
||||
|
||||
if ( jQuery.ajax ) {
|
||||
QUnit.test( "ajax", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
|
||||
|
||||
jQuery.ajax( {
|
||||
type: "GET",
|
||||
url: url( "data/name.php?name=foo" ),
|
||||
success: function( msg ) {
|
||||
assert.strictEqual( msg, "bar", "Check for GET" );
|
||||
done.pop()();
|
||||
}
|
||||
} );
|
||||
|
||||
jQuery.ajax( {
|
||||
type: "POST",
|
||||
url: url( "data/name.php" ),
|
||||
data: "name=peter",
|
||||
success: function( msg ) {
|
||||
assert.strictEqual( msg, "pan", "Check for POST" );
|
||||
done.pop()();
|
||||
}
|
||||
} );
|
||||
|
||||
jQuery( "#first" ).load( url( "data/name.html" ), function() {
|
||||
assert.ok( /^ERROR/.test( jQuery( "#first" ).text() ),
|
||||
"Check if content was injected into the DOM" );
|
||||
done.pop()();
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
QUnit.test( "attributes", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var a = jQuery( "<a/>" ).appendTo( "#qunit-fixture" ),
|
||||
input = jQuery( "<input/>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
assert.strictEqual( a.attr( "foo", "bar" ).attr( "foo" ), "bar", ".attr getter/setter" );
|
||||
assert.strictEqual( a.removeAttr( "foo" ).attr( "foo" ), undefined, ".removeAttr" );
|
||||
assert.strictEqual( a.prop( "href", "#5" ).prop( "href" ),
|
||||
location.href.replace( /\#.*$/, "" ) + "#5",
|
||||
".prop getter/setter" );
|
||||
|
||||
a.addClass( "abc def ghj" ).removeClass( "def ghj" );
|
||||
assert.strictEqual( a.hasClass( "abc" ), true, ".(add|remove|has)Class, class present" );
|
||||
assert.strictEqual( a.hasClass( "def" ), false, ".(add|remove|has)Class, class missing" );
|
||||
|
||||
assert.strictEqual( input.val( "xyz" ).val(), "xyz", ".val getter/setter" );
|
||||
} );
|
||||
|
||||
if ( jQuery.css ) {
|
||||
QUnit.test( "css", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var div = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
assert.strictEqual( div.css( "width", "50px" ).css( "width" ), "50px", ".css getter/setter" );
|
||||
|
||||
div.hide();
|
||||
assert.strictEqual( div.css( "display" ), "none", "div hidden" );
|
||||
div.show();
|
||||
assert.strictEqual( div.css( "display" ), "block", "div shown" );
|
||||
} );
|
||||
}
|
||||
|
||||
QUnit.test( "core", function( assert ) {
|
||||
assert.expect( 28 );
|
||||
|
||||
var elem = jQuery( "<div></div><span></span>" );
|
||||
|
||||
assert.strictEqual( elem.length, 2, "Correct number of elements" );
|
||||
assert.strictEqual( jQuery.trim( " hello " ), "hello", "jQuery.trim" );
|
||||
|
||||
assert.strictEqual( jQuery.type( null ), "null", "jQuery.type(null)" );
|
||||
assert.strictEqual( jQuery.type( undefined ), "undefined", "jQuery.type(undefined)" );
|
||||
assert.strictEqual( jQuery.type( "a" ), "string", "jQuery.type(String)" );
|
||||
|
||||
assert.ok( jQuery.isPlainObject( { "a": 2 } ), "jQuery.isPlainObject(object)" );
|
||||
assert.ok( !jQuery.isPlainObject( "foo" ), "jQuery.isPlainObject(String)" );
|
||||
|
||||
assert.ok( jQuery.isFunction( jQuery.noop ), "jQuery.isFunction(jQuery.noop)" );
|
||||
assert.ok( !jQuery.isFunction( 2 ), "jQuery.isFunction(Number)" );
|
||||
|
||||
assert.ok( jQuery.isNumeric( "-2" ), "jQuery.isNumeric(String representing a number)" );
|
||||
assert.ok( !jQuery.isNumeric( "" ), "jQuery.isNumeric(\"\")" );
|
||||
|
||||
assert.ok( jQuery.isXMLDoc( jQuery.parseXML(
|
||||
"<?xml version='1.0' encoding='UTF-8'?><foo bar='baz'></foo>"
|
||||
) ), "jQuery.isXMLDoc" );
|
||||
|
||||
assert.ok( jQuery.isWindow( window ), "jQuery.isWindow(window)" );
|
||||
assert.ok( !jQuery.isWindow( 2 ), "jQuery.isWindow(Number)" );
|
||||
|
||||
assert.strictEqual( jQuery.inArray( 3, [ "a", 6, false, 3, {} ] ), 3, "jQuery.inArray - true" );
|
||||
assert.strictEqual(
|
||||
jQuery.inArray( 3, [ "a", 6, false, "3", {} ] ),
|
||||
-1,
|
||||
"jQuery.inArray - false"
|
||||
);
|
||||
|
||||
assert.strictEqual( elem.get( 1 ), elem[ 1 ], ".get" );
|
||||
assert.strictEqual( elem.first()[ 0 ], elem[ 0 ], ".first" );
|
||||
assert.strictEqual( elem.last()[ 0 ], elem[ 1 ], ".last" );
|
||||
|
||||
assert.deepEqual( jQuery.map( [ "a", "b", "c" ], function( v, k ) {
|
||||
return k + v;
|
||||
} ), [ "0a", "1b", "2c" ], "jQuery.map" );
|
||||
|
||||
assert.deepEqual( jQuery.merge( [ 1, 2 ], [ "a", "b" ] ), [ 1, 2, "a", "b" ], "jQuery.merge" );
|
||||
|
||||
assert.deepEqual( jQuery.grep( [ 1, 2, 3 ], function( value ) {
|
||||
return value % 2 !== 0;
|
||||
} ), [ 1, 3 ], "jQuery.grep" );
|
||||
|
||||
assert.deepEqual( jQuery.extend( { a: 2 }, { b: 3 } ), { a: 2, b: 3 }, "jQuery.extend" );
|
||||
|
||||
jQuery.each( [ 0, 2 ], function( k, v ) {
|
||||
assert.strictEqual( k * 2, v, "jQuery.each" );
|
||||
} );
|
||||
|
||||
assert.deepEqual( jQuery.makeArray( { 0: "a", 1: "b", 2: "c", length: 3 } ),
|
||||
[ "a", "b", "c" ], "jQuery.makeArray" );
|
||||
|
||||
assert.strictEqual( jQuery.parseHTML( "<div></div><span></span>" ).length,
|
||||
2, "jQuery.parseHTML" );
|
||||
|
||||
assert.deepEqual( jQuery.parseJSON( "{\"a\": 2}" ), { a: 2 }, "jQuery.parseJON" );
|
||||
} );
|
||||
|
||||
QUnit.test( "data", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var elem = jQuery( "<div data-c='d'/>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
assert.ok( !jQuery.hasData( elem[ 0 ] ), "jQuery.hasData - false" );
|
||||
assert.strictEqual( elem.data( "a", "b" ).data( "a" ), "b", ".data getter/setter" );
|
||||
assert.strictEqual( elem.data( "c" ), "d", ".data from data-* attributes" );
|
||||
assert.ok( jQuery.hasData( elem[ 0 ] ), "jQuery.hasData - true" );
|
||||
} );
|
||||
|
||||
QUnit.test( "dimensions", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var elem = jQuery(
|
||||
"<div style='margin: 10px; padding: 7px; border: 2px solid black;' /> "
|
||||
).appendTo( "#qunit-fixture" );
|
||||
|
||||
assert.strictEqual( elem.width( 50 ).width(), 50, ".width getter/setter" );
|
||||
assert.strictEqual( elem.innerWidth(), 64, ".innerWidth getter" );
|
||||
assert.strictEqual( elem.outerWidth(), 68, ".outerWidth getter" );
|
||||
} );
|
||||
|
||||
QUnit.test( "event", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var elem = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
elem
|
||||
.on( "click", function() {
|
||||
assert.ok( false, "click should not fire" );
|
||||
} )
|
||||
.off( "click" )
|
||||
.trigger( "click" )
|
||||
.on( "click", function() {
|
||||
assert.ok( true, "click should fire" );
|
||||
} )
|
||||
.trigger( "click" );
|
||||
} );
|
||||
|
||||
QUnit.test( "manipulation", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var child,
|
||||
elem1 = jQuery( "<div><span></span></div>" ).appendTo( "#qunit-fixture" ),
|
||||
elem2 = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
assert.strictEqual( elem1.text( "foo" ).text(), "foo", ".html getter/setter" );
|
||||
|
||||
assert.strictEqual(
|
||||
|
||||
// Support: IE 8 only
|
||||
// IE 8 prints tag names in upper case.
|
||||
elem1.html( "<span/>" ).html().toLowerCase(),
|
||||
"<span></span>",
|
||||
".html getter/setter"
|
||||
);
|
||||
|
||||
assert.strictEqual( elem1.append( elem2 )[ 0 ].childNodes[ 1 ], elem2[ 0 ], ".append" );
|
||||
assert.strictEqual( elem1.prepend( elem2 )[ 0 ].childNodes[ 0 ], elem2[ 0 ], ".prepend" );
|
||||
|
||||
child = elem1.find( "span" );
|
||||
child.after( "<a/>" );
|
||||
child.before( "<b/>" );
|
||||
|
||||
assert.strictEqual(
|
||||
|
||||
// Support: IE 8 only
|
||||
// IE 8 prints tag names in upper case.
|
||||
elem1.html().toLowerCase(),
|
||||
"<div></div><b></b><span></span><a></a>",
|
||||
".after/.before"
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "offset", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var parent = jQuery( "<div style='position:fixed;top:20px;'/>" ).appendTo( "#qunit-fixture" ),
|
||||
elem = jQuery( "<div style='position:absolute;top:5px;'/>" ).appendTo( parent );
|
||||
|
||||
assert.strictEqual( elem.offset().top, 25, ".offset getter" );
|
||||
assert.strictEqual( elem.position().top, 5, ".position getter" );
|
||||
assert.strictEqual( elem.offsetParent()[ 0 ], parent[ 0 ], ".offsetParent" );
|
||||
} );
|
||||
|
||||
QUnit.test( "selector", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var elem = jQuery( "<div><span class='a'></span><span class='b'><a></a></span></div>" )
|
||||
.appendTo( "#qunit-fixture" );
|
||||
|
||||
assert.strictEqual( elem.find( ".a a" ).length, 0, ".find - no result" );
|
||||
assert.strictEqual( elem.find( "span.b a" )[ 0 ].nodeName, "A", ".find - one result" );
|
||||
} );
|
||||
|
||||
QUnit.test( "serialize", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var params = { "someName": [ 1, 2, 3 ], "regularThing": "blah" };
|
||||
assert.strictEqual( jQuery.param( params ),
|
||||
"someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah",
|
||||
"jQuery.param" );
|
||||
|
||||
assert.strictEqual( jQuery( "#form" ).serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search" +
|
||||
"&select1=&select2=3&select3=1&select3=2&select5=3",
|
||||
"form serialization as query string" );
|
||||
} );
|
||||
|
||||
QUnit.test( "traversing", function( assert ) {
|
||||
assert.expect( 12 );
|
||||
|
||||
var elem = jQuery( "<div><a><b><em></em></b></a><i></i><span></span>foo</div>" )
|
||||
.appendTo( "#qunit-fixture" );
|
||||
|
||||
assert.strictEqual( elem.find( "em" ).parent()[ 0 ].nodeName, "B", ".parent" );
|
||||
assert.strictEqual( elem.find( "em" ).parents()[ 1 ].nodeName, "A", ".parents" );
|
||||
assert.strictEqual( elem.find( "em" ).parentsUntil( "div" ).length, 2, ".parentsUntil" );
|
||||
assert.strictEqual( elem.find( "i" ).next()[ 0 ].nodeName, "SPAN", ".next" );
|
||||
assert.strictEqual( elem.find( "i" ).prev()[ 0 ].nodeName, "A", ".prev" );
|
||||
assert.strictEqual( elem.find( "a" ).nextAll()[ 1 ].nodeName, "SPAN", ".nextAll" );
|
||||
assert.strictEqual( elem.find( "span" ).prevAll()[ 1 ].nodeName, "A", ".prevAll" );
|
||||
assert.strictEqual( elem.find( "a" ).nextUntil( "span" ).length, 1, ".nextUntil" );
|
||||
assert.strictEqual( elem.find( "span" ).prevUntil( "a" ).length, 1, ".prevUntil" );
|
||||
assert.strictEqual( elem.find( "i" ).siblings().length, 2, ".siblings" );
|
||||
assert.strictEqual( elem.children()[ 2 ].nodeName, "SPAN", ".children" );
|
||||
assert.strictEqual( elem.contents()[ 3 ].nodeType, 3, ".contents" );
|
||||
} );
|
||||
|
||||
QUnit.test( "wrap", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var elem = jQuery( "<div><a><b></b></a><a></a></div>" );
|
||||
|
||||
elem.find( "b" ).wrap( "<span>" );
|
||||
|
||||
assert.strictEqual(
|
||||
|
||||
// Support: IE 8 only
|
||||
// IE 8 prints tag names in upper case.
|
||||
elem.html().toLowerCase(),
|
||||
"<a><span><b></b></span></a><a></a>",
|
||||
".wrap"
|
||||
);
|
||||
|
||||
elem.find( "span" ).wrapInner( "<em>" );
|
||||
|
||||
assert.strictEqual(
|
||||
|
||||
// Support: IE 8 only
|
||||
// IE 8 prints tag names in upper case.
|
||||
elem.html().toLowerCase(),
|
||||
"<a><span><em><b></b></em></span></a><a></a>",
|
||||
".wrapInner"
|
||||
);
|
||||
|
||||
elem.find( "a" ).wrapAll( "<i>" );
|
||||
|
||||
assert.strictEqual(
|
||||
|
||||
// Support: IE 8 only
|
||||
// IE 8 prints tag names in upper case.
|
||||
elem.html().toLowerCase(),
|
||||
"<i><a><span><em><b></b></em></span></a><a></a></i>",
|
||||
".wrapAll"
|
||||
);
|
||||
|
||||
} );
|
358
dashboard-ui/bower_components/jquery/test/unit/callbacks.js
vendored
Normal file
358
dashboard-ui/bower_components/jquery/test/unit/callbacks.js
vendored
Normal file
|
@ -0,0 +1,358 @@
|
|||
QUnit.module( "callbacks", {
|
||||
teardown: moduleTeardown
|
||||
} );
|
||||
|
||||
( function() {
|
||||
|
||||
var output,
|
||||
addToOutput = function( string ) {
|
||||
return function() {
|
||||
output += string;
|
||||
};
|
||||
},
|
||||
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",
|
||||
"memory": "XABC XABC XABCABCCC XA XBB XB XABA XC XX",
|
||||
"unique": "XABC X XABCA X XBB X XAB X X",
|
||||
"stopOnFalse": "XABC X XABCABCC X XBB X XA X XX",
|
||||
"once memory": "XABC XABC X XA X XA XABA XC XX",
|
||||
"once unique": "XABC X X X X X XAB X X",
|
||||
"once stopOnFalse": "XABC X X X X X XA X XX",
|
||||
"memory unique": "XABC XA XABCA XA XBB XB XAB XC X",
|
||||
"memory stopOnFalse": "XABC XABC XABCABCCC XA XBB XB XA X XX",
|
||||
"unique stopOnFalse": "XABC X XABCA X XBB X XA X X"
|
||||
},
|
||||
filters = {
|
||||
"no filter": undefined,
|
||||
"filter": function( fn ) {
|
||||
return function() {
|
||||
return fn.apply( this, arguments );
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
function showFlags( flags ) {
|
||||
if ( typeof flags === "string" ) {
|
||||
return "'" + flags + "'";
|
||||
}
|
||||
var output = [], key;
|
||||
for ( key in flags ) {
|
||||
output.push( "'" + key + "': " + flags[ key ] );
|
||||
}
|
||||
return "{ " + output.join( ", " ) + " }";
|
||||
}
|
||||
|
||||
jQuery.each( tests, function( strFlags, resultString ) {
|
||||
|
||||
var objectFlags = {};
|
||||
|
||||
jQuery.each( strFlags.split( " " ), function() {
|
||||
if ( this.length ) {
|
||||
objectFlags[ this ] = true;
|
||||
}
|
||||
} );
|
||||
|
||||
jQuery.each( filters, function( filterLabel ) {
|
||||
|
||||
jQuery.each( {
|
||||
"string": strFlags,
|
||||
"object": objectFlags
|
||||
}, function( flagsTypes, flags ) {
|
||||
|
||||
QUnit.test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function( assert ) {
|
||||
|
||||
assert.expect( 28 );
|
||||
|
||||
var cblist,
|
||||
results = resultString.split( /\s+/ );
|
||||
|
||||
// Basic binding and firing
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
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 ) {
|
||||
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 ) {
|
||||
output += str;
|
||||
});
|
||||
assert.strictEqual( output, "X", "Adding a callback after disabling" );
|
||||
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" );
|
||||
|
||||
// Emptying while firing (#13517)
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add( cblist.empty );
|
||||
cblist.add( function() {
|
||||
assert.ok( false, "not emptied" );
|
||||
} );
|
||||
cblist.fire();
|
||||
|
||||
// Disabling while firing
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add( cblist.disable );
|
||||
cblist.add( function() {
|
||||
assert.ok( false, "not disabled" );
|
||||
} );
|
||||
cblist.fire();
|
||||
|
||||
// Basic binding and firing (context, arguments)
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
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() {
|
||||
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
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add( outputA, outputB, outputC );
|
||||
cblist.remove( outputB, outputC );
|
||||
cblist.fire();
|
||||
assert.strictEqual( output, "XA", "Basic binding, removing and firing" );
|
||||
|
||||
// Empty
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add( outputA );
|
||||
cblist.add( outputB );
|
||||
cblist.add( outputC );
|
||||
cblist.empty();
|
||||
cblist.fire();
|
||||
assert.strictEqual( output, "X", "Empty" );
|
||||
|
||||
// Locking
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add(function( str ) {
|
||||
output += str;
|
||||
});
|
||||
cblist.lock();
|
||||
cblist.add(function( str ) {
|
||||
output += 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" );
|
||||
|
||||
// Ordering
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add(function() {
|
||||
cblist.add( outputC );
|
||||
outputA();
|
||||
}, outputB );
|
||||
cblist.fire();
|
||||
assert.strictEqual( output, results.shift(), "Proper ordering" );
|
||||
|
||||
// Add and fire again
|
||||
output = "X";
|
||||
cblist.add(function() {
|
||||
cblist.add( outputC );
|
||||
outputA();
|
||||
}, outputB );
|
||||
assert.strictEqual( output, results.shift(), "Add after fire" );
|
||||
|
||||
output = "X";
|
||||
cblist.fire();
|
||||
assert.strictEqual( output, results.shift(), "Fire again" );
|
||||
|
||||
// Multiple fire
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add(function( str ) {
|
||||
output += str;
|
||||
});
|
||||
cblist.fire("A");
|
||||
assert.strictEqual( output, "XA", "Multiple fire (first fire)" );
|
||||
output = "X";
|
||||
cblist.add(function( str ) {
|
||||
output += str;
|
||||
});
|
||||
assert.strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
|
||||
output = "X";
|
||||
cblist.fire("B");
|
||||
assert.strictEqual( output, results.shift(), "Multiple fire (second fire)" );
|
||||
output = "X";
|
||||
cblist.add(function( str ) {
|
||||
output += str;
|
||||
});
|
||||
assert.strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
|
||||
|
||||
// Return false
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add( outputA, function() { return false; }, outputB );
|
||||
cblist.add( outputA );
|
||||
cblist.fire();
|
||||
assert.strictEqual( output, results.shift(), "Callback returning false" );
|
||||
|
||||
// Add another callback (to control lists with memory do not fire anymore)
|
||||
output = "X";
|
||||
cblist.add( outputC );
|
||||
assert.strictEqual( output, results.shift(), "Adding a callback after one returned false" );
|
||||
|
||||
// Callbacks are not iterated
|
||||
output = "";
|
||||
function handler() {
|
||||
output += "X";
|
||||
}
|
||||
handler.method = function() {
|
||||
output += "!";
|
||||
};
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add( handler );
|
||||
cblist.add( handler );
|
||||
cblist.fire();
|
||||
assert.strictEqual( output, results.shift(), "No callback iteration" );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
} )();
|
||||
|
||||
QUnit.test( "jQuery.Callbacks( options ) - options are copied", function( assert ) {
|
||||
|
||||
assert.expect( 1 );
|
||||
|
||||
var options = {
|
||||
"unique": true
|
||||
},
|
||||
cb = jQuery.Callbacks( options ),
|
||||
count = 0,
|
||||
fn = function() {
|
||||
assert.ok( !( count++ ), "called once" );
|
||||
};
|
||||
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" ];
|
||||
|
||||
cb.fireWith( null, args );
|
||||
args[ 0 ] = "world";
|
||||
|
||||
cb.add( function( hello ) {
|
||||
assert.strictEqual( hello, "hello", "arguments are copied internally" );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Callbacks.remove - should remove all instances", function( assert ) {
|
||||
|
||||
assert.expect( 1 );
|
||||
|
||||
var cb = jQuery.Callbacks();
|
||||
|
||||
function fn() {
|
||||
assert.ok( false, "function wasn't removed" );
|
||||
}
|
||||
|
||||
cb.add( fn, fn, function() {
|
||||
assert.ok( true, "end of test" );
|
||||
} ).remove( fn ).fire();
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Callbacks.has", function( assert ) {
|
||||
|
||||
assert.expect( 13 );
|
||||
|
||||
var cb = jQuery.Callbacks();
|
||||
function getA() {
|
||||
return "A";
|
||||
}
|
||||
function getB() {
|
||||
return "B";
|
||||
}
|
||||
function getC() {
|
||||
return "C";
|
||||
}
|
||||
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" );
|
||||
|
||||
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" );
|
||||
|
||||
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(), 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" );
|
||||
|
||||
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 ) {
|
||||
|
||||
assert.expect( 1 );
|
||||
|
||||
jQuery.Callbacks().add( "hello world" );
|
||||
|
||||
assert.ok( true, "no stack overflow" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", function( assert ) {
|
||||
|
||||
assert.expect( 1 );
|
||||
|
||||
var cb = jQuery.Callbacks(),
|
||||
fired = false,
|
||||
shot = function() { fired = true; };
|
||||
|
||||
cb.disable();
|
||||
cb.empty();
|
||||
cb.add( shot );
|
||||
cb.fire();
|
||||
assert.ok( !fired, "Disabled callback function didn't fire" );
|
||||
} );
|
1711
dashboard-ui/bower_components/jquery/test/unit/core.js
vendored
Normal file
1711
dashboard-ui/bower_components/jquery/test/unit/core.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
1298
dashboard-ui/bower_components/jquery/test/unit/css.js
vendored
Normal file
1298
dashboard-ui/bower_components/jquery/test/unit/css.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
889
dashboard-ui/bower_components/jquery/test/unit/data.js
vendored
Normal file
889
dashboard-ui/bower_components/jquery/test/unit/data.js
vendored
Normal file
|
@ -0,0 +1,889 @@
|
|||
QUnit.module( "data", { teardown: moduleTeardown } );
|
||||
|
||||
QUnit.test( "expando", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
assert.equal( jQuery.expando !== undefined, true, "jQuery is exposing the expando" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.data & removeData, expected returns", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
var elem = document.body;
|
||||
|
||||
assert.equal(
|
||||
jQuery.data( elem, "hello", "world" ), "world",
|
||||
"jQuery.data( elem, key, value ) returns value"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery.data( elem, "hello" ), "world",
|
||||
"jQuery.data( elem, key ) returns value"
|
||||
);
|
||||
assert.deepEqual(
|
||||
jQuery.data( elem, { goodnight: "moon" } ), { goodnight: "moon" },
|
||||
"jQuery.data( elem, obj ) returns obj"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery.removeData( elem, "hello" ), undefined,
|
||||
"jQuery.removeData( elem, key, value ) returns undefined"
|
||||
);
|
||||
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery._data & _removeData, expected returns", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
var elem = document.body;
|
||||
|
||||
assert.equal(
|
||||
jQuery._data( elem, "hello", "world" ), "world",
|
||||
"jQuery._data( elem, key, value ) returns value"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery._data( elem, "hello" ), "world",
|
||||
"jQuery._data( elem, key ) returns value"
|
||||
);
|
||||
assert.deepEqual(
|
||||
jQuery._data( elem, { goodnight: "moon" } ), { goodnight: "moon" },
|
||||
"jQuery._data( elem, obj ) returns obj"
|
||||
);
|
||||
assert.equal(
|
||||
jQuery._removeData( elem, "hello" ), undefined,
|
||||
"jQuery._removeData( elem, key, value ) returns undefined"
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.hasData no side effects", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
var obj = {};
|
||||
|
||||
jQuery.hasData( obj );
|
||||
|
||||
assert.equal( Object.getOwnPropertyNames( obj ).length, 0,
|
||||
"No data expandos where added when calling jQuery.hasData(o)"
|
||||
);
|
||||
} );
|
||||
|
||||
function dataTests( elem, assert ) {
|
||||
var dataObj, internalDataObj;
|
||||
|
||||
assert.equal( jQuery.data( elem, "foo" ), undefined, "No data exists initially" );
|
||||
assert.strictEqual( jQuery.hasData( elem ), false, "jQuery.hasData agrees no data exists initially" );
|
||||
|
||||
dataObj = jQuery.data( elem );
|
||||
assert.equal( typeof dataObj, "object", "Calling data with no args gives us a data object reference" );
|
||||
assert.strictEqual( jQuery.data( elem ), dataObj, "Calling jQuery.data returns the same data object when called multiple times" );
|
||||
|
||||
assert.strictEqual( jQuery.hasData( elem ), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" );
|
||||
|
||||
dataObj[ "foo" ] = "bar";
|
||||
assert.equal( jQuery.data( elem, "foo" ), "bar", "Data is readable by jQuery.data when set directly on a returned data object" );
|
||||
|
||||
assert.strictEqual( jQuery.hasData( elem ), true, "jQuery.hasData agrees data exists when data exists" );
|
||||
|
||||
jQuery.data( elem, "foo", "baz" );
|
||||
assert.equal( jQuery.data( elem, "foo" ), "baz", "Data can be changed by jQuery.data" );
|
||||
assert.equal( dataObj[ "foo" ], "baz", "Changes made through jQuery.data propagate to referenced data object" );
|
||||
|
||||
jQuery.data( elem, "foo", undefined );
|
||||
assert.equal( jQuery.data( elem, "foo" ), "baz", "Data is not unset by passing undefined to jQuery.data" );
|
||||
|
||||
jQuery.data( elem, "foo", null );
|
||||
assert.strictEqual( jQuery.data( elem, "foo" ), null, "Setting null using jQuery.data works OK" );
|
||||
|
||||
jQuery.data( elem, "foo", "foo1" );
|
||||
|
||||
jQuery.data( elem, { "bar": "baz", "boom": "bloz" } );
|
||||
assert.strictEqual( jQuery.data( elem, "foo" ), "foo1", "Passing an object extends the data object instead of replacing it" );
|
||||
assert.equal( jQuery.data( elem, "boom" ), "bloz", "Extending the data object works" );
|
||||
|
||||
jQuery._data( elem, "foo", "foo2", true );
|
||||
assert.equal( jQuery._data( elem, "foo" ), "foo2", "Setting internal data works" );
|
||||
assert.equal( jQuery.data( elem, "foo" ), "foo1", "Setting internal data does not override user data" );
|
||||
|
||||
internalDataObj = jQuery._data( elem );
|
||||
assert.ok( internalDataObj, "Internal data object exists" );
|
||||
assert.notStrictEqual( dataObj, internalDataObj, "Internal data object is not the same as user data object" );
|
||||
|
||||
assert.strictEqual( elem.boom, undefined, "Data is never stored directly on the object" );
|
||||
|
||||
jQuery.removeData( elem, "foo" );
|
||||
assert.strictEqual( jQuery.data( elem, "foo" ), undefined, "jQuery.removeData removes single properties" );
|
||||
|
||||
jQuery.removeData( elem );
|
||||
assert.strictEqual( jQuery._data( elem ), internalDataObj, "jQuery.removeData does not remove internal data if it exists" );
|
||||
|
||||
jQuery.data( elem, "foo", "foo1" );
|
||||
jQuery._data( elem, "foo", "foo2" );
|
||||
|
||||
assert.equal( jQuery.data( elem, "foo" ), "foo1", "(sanity check) Ensure data is set in user data object" );
|
||||
assert.equal( jQuery._data( elem, "foo" ), "foo2", "(sanity check) Ensure data is set in internal data object" );
|
||||
|
||||
assert.strictEqual( jQuery._data( elem, jQuery.expando ), undefined, "Removing the last item in internal data destroys the internal data object" );
|
||||
|
||||
jQuery._data( elem, "foo", "foo2" );
|
||||
assert.equal( jQuery._data( elem, "foo" ), "foo2", "(sanity check) Ensure data is set in internal data object" );
|
||||
|
||||
jQuery.removeData( elem, "foo" );
|
||||
assert.equal( jQuery._data( elem, "foo" ), "foo2", "(sanity check) jQuery.removeData for user data does not remove internal data" );
|
||||
}
|
||||
|
||||
QUnit.test( "jQuery.data(div)", function( assert ) {
|
||||
assert.expect( 25 );
|
||||
|
||||
var div = document.createElement( "div" );
|
||||
|
||||
dataTests( div, assert );
|
||||
|
||||
// We stored one key in the private data
|
||||
// assert that nothing else was put in there, and that that
|
||||
// one stayed there.
|
||||
assert.expectJqData( this, div, "foo" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.data({})", function( assert ) {
|
||||
assert.expect( 25 );
|
||||
|
||||
dataTests( {}, assert );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.data(window)", function( assert ) {
|
||||
assert.expect( 25 );
|
||||
|
||||
// remove bound handlers from window object to stop potential false positives caused by fix for #5280 in
|
||||
// transports/xhr.js
|
||||
jQuery( window ).off( "unload" );
|
||||
|
||||
dataTests( window, assert );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.data(document)", function( assert ) {
|
||||
assert.expect( 25 );
|
||||
|
||||
dataTests( document, assert );
|
||||
|
||||
assert.expectJqData( this, document, "foo" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.data(<embed>)", function( assert ) {
|
||||
assert.expect( 25 );
|
||||
|
||||
dataTests( document.createElement( "embed" ), assert );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.data(object/flash)", function( assert ) {
|
||||
assert.expect( 25 );
|
||||
|
||||
var flash = document.createElement( "object" );
|
||||
flash.setAttribute( "classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" );
|
||||
|
||||
dataTests( flash, assert );
|
||||
} );
|
||||
|
||||
// attempting to access the data of an undefined jQuery element should be undefined
|
||||
QUnit.test( "jQuery().data() === undefined (#14101)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
assert.strictEqual( jQuery().data(), undefined );
|
||||
assert.strictEqual( jQuery().data( "key" ), undefined );
|
||||
} );
|
||||
|
||||
QUnit.test( ".data()", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var div, dataObj, nodiv, obj;
|
||||
|
||||
div = jQuery( "#foo" );
|
||||
assert.strictEqual( div.data( "foo" ), undefined, "Make sure that missing result is undefined" );
|
||||
div.data( "test", "success" );
|
||||
|
||||
dataObj = div.data();
|
||||
|
||||
assert.deepEqual( dataObj, { test: "success" }, "data() returns entire data object with expected properties" );
|
||||
assert.strictEqual( div.data( "foo" ), undefined, "Make sure that missing result is still undefined" );
|
||||
|
||||
nodiv = jQuery( "#unfound" );
|
||||
assert.equal( nodiv.data(), null, "data() on empty set returns null" );
|
||||
|
||||
obj = { foo: "bar" };
|
||||
jQuery( obj ).data( "foo", "baz" );
|
||||
|
||||
dataObj = jQuery.extend( true, {}, jQuery( obj ).data() );
|
||||
|
||||
assert.deepEqual( dataObj, { "foo": "baz" }, "Retrieve data object from a wrapped JS object (#7524)" );
|
||||
} );
|
||||
|
||||
function testDataTypes( $obj, assert ) {
|
||||
jQuery.each( {
|
||||
"null": null,
|
||||
"true": true,
|
||||
"false": false,
|
||||
"zero": 0,
|
||||
"one": 1,
|
||||
"empty string": "",
|
||||
"empty array": [],
|
||||
"array": [ 1 ],
|
||||
"empty object": {},
|
||||
"object": { foo: "bar" },
|
||||
"date": new Date(),
|
||||
"regex": /test/,
|
||||
"function": function() {}
|
||||
}, function( type, value ) {
|
||||
assert.strictEqual( $obj.data( "test", value ).data( "test" ), value, "Data set to " + type );
|
||||
} );
|
||||
}
|
||||
|
||||
QUnit.test( "jQuery(Element).data(String, Object).data(String)", function( assert ) {
|
||||
assert.expect( 18 );
|
||||
var parent = jQuery( "<div><div></div></div>" ),
|
||||
div = parent.children();
|
||||
|
||||
assert.strictEqual( div.data( "test" ), undefined, "No data exists initially" );
|
||||
assert.strictEqual( div.data( "test", "success" ).data( "test" ), "success", "Data added" );
|
||||
assert.strictEqual( div.data( "test", "overwritten" ).data( "test" ), "overwritten", "Data overwritten" );
|
||||
assert.strictEqual( div.data( "test", undefined ).data( "test" ), "overwritten", ".data(key,undefined) does nothing but is chainable (#5571)" );
|
||||
assert.strictEqual( div.data( "notexist" ), undefined, "No data exists for unset key" );
|
||||
testDataTypes( div, assert );
|
||||
|
||||
parent.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery(plain Object).data(String, Object).data(String)", function( assert ) {
|
||||
assert.expect( 16 );
|
||||
|
||||
// #3748
|
||||
var $obj = jQuery( { exists: true } );
|
||||
assert.strictEqual( $obj.data( "nothing" ), undefined, "Non-existent data returns undefined" );
|
||||
assert.strictEqual( $obj.data( "exists" ), undefined, "Object properties are not returned as data" );
|
||||
testDataTypes( $obj, assert );
|
||||
|
||||
// Clean up
|
||||
$obj.removeData();
|
||||
assert.deepEqual( $obj[ 0 ], { exists: true }, "removeData does not clear the object" );
|
||||
} );
|
||||
|
||||
QUnit.test( ".data(object) does not retain references. #13815", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var $divs = jQuery( "<div></div><div></div>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
$divs.data( { "type": "foo" } );
|
||||
$divs.eq( 0 ).data( "type", "bar" );
|
||||
|
||||
assert.equal( $divs.eq( 0 ).data( "type" ), "bar", "Correct updated value" );
|
||||
assert.equal( $divs.eq( 1 ).data( "type" ), "foo", "Original value retained" );
|
||||
} );
|
||||
|
||||
QUnit.test( "data-* attributes", function( assert ) {
|
||||
assert.expect( 43 );
|
||||
|
||||
var prop, i, l, metadata, elem,
|
||||
obj, obj2, check, num, num2,
|
||||
parseJSON = jQuery.parseJSON,
|
||||
div = jQuery( "<div>" ),
|
||||
child = jQuery( "<div data-myobj='old data' data-ignored=\"DOM\" data-other='test'></div>" ),
|
||||
dummy = jQuery( "<div data-myobj='old data' data-ignored=\"DOM\" data-other='test'></div>" );
|
||||
|
||||
assert.equal( div.data( "attr" ), undefined, "Check for non-existing data-attr attribute" );
|
||||
|
||||
div.attr( "data-attr", "exists" );
|
||||
assert.equal( div.data( "attr" ), "exists", "Check for existing data-attr attribute" );
|
||||
|
||||
div.attr( "data-attr", "exists2" );
|
||||
assert.equal( div.data( "attr" ), "exists", "Check that updates to data- don't update .data()" );
|
||||
|
||||
div.data( "attr", "internal" ).attr( "data-attr", "external" );
|
||||
assert.equal( div.data( "attr" ), "internal", "Check for .data('attr') precedence (internal > external data-* attribute)" );
|
||||
|
||||
div.remove();
|
||||
|
||||
child.appendTo( "#qunit-fixture" );
|
||||
assert.equal( child.data( "myobj" ), "old data", "Value accessed from data-* attribute" );
|
||||
|
||||
child.data( "myobj", "replaced" );
|
||||
assert.equal( child.data( "myobj" ), "replaced", "Original data overwritten" );
|
||||
|
||||
child.data( "ignored", "cache" );
|
||||
assert.equal( child.data( "ignored" ), "cache", "Cached data used before DOM data-* fallback" );
|
||||
|
||||
obj = child.data();
|
||||
obj2 = dummy.data();
|
||||
check = [ "myobj", "ignored", "other" ];
|
||||
num = 0;
|
||||
num2 = 0;
|
||||
|
||||
dummy.remove();
|
||||
|
||||
for ( i = 0, l = check.length; i < l; i++ ) {
|
||||
assert.ok( obj[ check[ i ] ], "Make sure data- property exists when calling data-." );
|
||||
assert.ok( obj2[ check[ i ] ], "Make sure data- property exists when calling data-." );
|
||||
}
|
||||
|
||||
for ( prop in obj ) {
|
||||
num++;
|
||||
}
|
||||
|
||||
assert.equal( num, check.length, "Make sure that the right number of properties came through." );
|
||||
|
||||
for ( prop in obj2 ) {
|
||||
num2++;
|
||||
}
|
||||
|
||||
assert.equal( num2, check.length, "Make sure that the right number of properties came through." );
|
||||
|
||||
child.attr( "data-other", "newvalue" );
|
||||
|
||||
assert.equal( child.data( "other" ), "test", "Make sure value was pulled in properly from a .data()." );
|
||||
|
||||
// attribute parsing
|
||||
i = 0;
|
||||
jQuery.parseJSON = function() {
|
||||
i++;
|
||||
return parseJSON.apply( this, arguments );
|
||||
};
|
||||
|
||||
child
|
||||
.attr( "data-true", "true" )
|
||||
.attr( "data-false", "false" )
|
||||
.attr( "data-five", "5" )
|
||||
.attr( "data-point", "5.5" )
|
||||
.attr( "data-pointe", "5.5E3" )
|
||||
.attr( "data-grande", "5.574E9" )
|
||||
.attr( "data-hexadecimal", "0x42" )
|
||||
.attr( "data-pointbad", "5..5" )
|
||||
.attr( "data-pointbad2", "-." )
|
||||
.attr( "data-bigassnum", "123456789123456789123456789" )
|
||||
.attr( "data-badjson", "{123}" )
|
||||
.attr( "data-badjson2", "[abc]" )
|
||||
.attr( "data-notjson", " {}" )
|
||||
.attr( "data-notjson2", "[] " )
|
||||
.attr( "data-empty", "" )
|
||||
.attr( "data-space", " " )
|
||||
.attr( "data-null", "null" )
|
||||
.attr( "data-string", "test" );
|
||||
|
||||
assert.strictEqual( child.data( "true" ), true, "Primitive true read from attribute" );
|
||||
assert.strictEqual( child.data( "false" ), false, "Primitive false read from attribute" );
|
||||
assert.strictEqual( child.data( "five" ), 5, "Integer read from attribute" );
|
||||
assert.strictEqual( child.data( "point" ), 5.5, "Floating-point number read from attribute" );
|
||||
assert.strictEqual( child.data( "pointe" ), "5.5E3",
|
||||
"Exponential-notation number read from attribute as string" );
|
||||
assert.strictEqual( child.data( "grande" ), "5.574E9",
|
||||
"Big exponential-notation number read from attribute as string" );
|
||||
assert.strictEqual( child.data( "hexadecimal" ), "0x42",
|
||||
"Hexadecimal number read from attribute as string" );
|
||||
assert.strictEqual( child.data( "pointbad" ), "5..5",
|
||||
"Extra-point non-number read from attribute as string" );
|
||||
assert.strictEqual( child.data( "pointbad2" ), "-.",
|
||||
"No-digit non-number read from attribute as string" );
|
||||
assert.strictEqual( child.data( "bigassnum" ), "123456789123456789123456789",
|
||||
"Bad bigass number read from attribute as string" );
|
||||
assert.strictEqual( child.data( "badjson" ), "{123}", "Bad JSON object read from attribute as string" );
|
||||
assert.strictEqual( child.data( "badjson2" ), "[abc]", "Bad JSON array read from attribute as string" );
|
||||
assert.strictEqual( child.data( "notjson" ), " {}",
|
||||
"JSON object with leading non-JSON read from attribute as string" );
|
||||
assert.strictEqual( child.data( "notjson2" ), "[] ",
|
||||
"JSON array with trailing non-JSON read from attribute as string" );
|
||||
assert.strictEqual( child.data( "empty" ), "", "Empty string read from attribute" );
|
||||
assert.strictEqual( child.data( "space" ), " ", "Whitespace string read from attribute" );
|
||||
assert.strictEqual( child.data( "null" ), null, "Primitive null read from attribute" );
|
||||
assert.strictEqual( child.data( "string" ), "test", "Typical string read from attribute" );
|
||||
assert.equal( i, 2, "Correct number of JSON parse attempts when reading from attributes" );
|
||||
|
||||
jQuery.parseJSON = parseJSON;
|
||||
child.remove();
|
||||
|
||||
// tests from metadata plugin
|
||||
function testData( index, elem ) {
|
||||
switch ( index ) {
|
||||
case 0:
|
||||
assert.equal( jQuery( elem ).data( "foo" ), "bar", "Check foo property" );
|
||||
assert.equal( jQuery( elem ).data( "bar" ), "baz", "Check baz property" );
|
||||
break;
|
||||
case 1:
|
||||
assert.equal( jQuery( elem ).data( "test" ), "bar", "Check test property" );
|
||||
assert.equal( jQuery( elem ).data( "bar" ), "baz", "Check bar property" );
|
||||
break;
|
||||
case 2:
|
||||
assert.equal( jQuery( elem ).data( "zoooo" ), "bar", "Check zoooo property" );
|
||||
assert.deepEqual( jQuery( elem ).data( "bar" ), { "test":"baz" }, "Check bar property" );
|
||||
break;
|
||||
case 3:
|
||||
assert.equal( jQuery( elem ).data( "number" ), true, "Check number property" );
|
||||
assert.deepEqual( jQuery( elem ).data( "stuff" ), [ 2, 8 ], "Check stuff property" );
|
||||
break;
|
||||
default:
|
||||
assert.ok( false, [ "Assertion failed on index ", index, ", with data" ].join( "" ) );
|
||||
}
|
||||
}
|
||||
|
||||
metadata = "<ol><li class='test test2' data-foo='bar' data-bar='baz' data-arr='[1,2]'>Some stuff</li><li class='test test2' data-test='bar' data-bar='baz'>Some stuff</li><li class='test test2' data-zoooo='bar' data-bar='{\"test\":\"baz\"}'>Some stuff</li><li class='test test2' data-number=true data-stuff='[2,8]'>Some stuff</li></ol>";
|
||||
elem = jQuery( metadata ).appendTo( "#qunit-fixture" );
|
||||
|
||||
elem.find( "li" ).each( testData );
|
||||
elem.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( ".data(Object)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var obj, jqobj,
|
||||
div = jQuery( "<div/>" );
|
||||
|
||||
div.data( { "test": "in", "test2": "in2" } );
|
||||
assert.equal( div.data( "test" ), "in", "Verify setting an object in data" );
|
||||
assert.equal( div.data( "test2" ), "in2", "Verify setting an object in data" );
|
||||
|
||||
obj = { test:"unset" };
|
||||
jqobj = jQuery( obj );
|
||||
|
||||
jqobj.data( "test", "unset" );
|
||||
jqobj.data( { "test": "in", "test2": "in2" } );
|
||||
assert.equal( jQuery.data( obj )[ "test" ], "in", "Verify setting an object on an object extends the data object" );
|
||||
assert.equal( obj[ "test2" ], undefined, "Verify setting an object on an object does not extend the object" );
|
||||
|
||||
// manually clean up detached elements
|
||||
div.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.removeData", function( assert ) {
|
||||
assert.expect( 10 );
|
||||
|
||||
var obj,
|
||||
div = jQuery( "#foo" )[ 0 ];
|
||||
jQuery.data( div, "test", "testing" );
|
||||
jQuery.removeData( div, "test" );
|
||||
assert.equal( jQuery.data( div, "test" ), undefined, "Check removal of data" );
|
||||
|
||||
jQuery.data( div, "test2", "testing" );
|
||||
jQuery.removeData( div );
|
||||
assert.ok( !jQuery.data( div, "test2" ), "Make sure that the data property no longer exists." );
|
||||
assert.ok( !div[ jQuery.expando ], "Make sure the expando no longer exists, as well." );
|
||||
|
||||
jQuery.data( div, {
|
||||
test3: "testing",
|
||||
test4: "testing"
|
||||
} );
|
||||
jQuery.removeData( div, "test3 test4" );
|
||||
assert.ok( !jQuery.data( div, "test3" ) || jQuery.data( div, "test4" ), "Multiple delete with spaces." );
|
||||
|
||||
jQuery.data( div, {
|
||||
test3: "testing",
|
||||
test4: "testing"
|
||||
} );
|
||||
jQuery.removeData( div, [ "test3", "test4" ] );
|
||||
assert.ok( !jQuery.data( div, "test3" ) || jQuery.data( div, "test4" ), "Multiple delete by array." );
|
||||
|
||||
jQuery.data( div, {
|
||||
"test3 test4": "testing",
|
||||
"test3": "testing"
|
||||
} );
|
||||
jQuery.removeData( div, "test3 test4" );
|
||||
assert.ok( !jQuery.data( div, "test3 test4" ), "Multiple delete with spaces deleted key with exact name" );
|
||||
assert.ok( jQuery.data( div, "test3" ), "Left the partial matched key alone" );
|
||||
|
||||
obj = {};
|
||||
jQuery.data( obj, "test", "testing" );
|
||||
assert.equal( jQuery( obj ).data( "test" ), "testing", "verify data on plain object" );
|
||||
jQuery.removeData( obj, "test" );
|
||||
assert.equal( jQuery.data( obj, "test" ), undefined, "Check removal of data on plain object" );
|
||||
|
||||
jQuery.data( window, "BAD", true );
|
||||
jQuery.removeData( window, "BAD" );
|
||||
assert.ok( !jQuery.data( window, "BAD" ), "Make sure that the value was not still set." );
|
||||
} );
|
||||
|
||||
QUnit.test( ".removeData()", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
var div = jQuery( "#foo" );
|
||||
div.data( "test", "testing" );
|
||||
div.removeData( "test" );
|
||||
assert.equal( div.data( "test" ), undefined, "Check removal of data" );
|
||||
|
||||
div.data( "test", "testing" );
|
||||
div.data( "test.foo", "testing2" );
|
||||
div.removeData( "test.bar" );
|
||||
assert.equal( div.data( "test.foo" ), "testing2", "Make sure data is intact" );
|
||||
assert.equal( div.data( "test" ), "testing", "Make sure data is intact" );
|
||||
|
||||
div.removeData( "test" );
|
||||
assert.equal( div.data( "test.foo" ), "testing2", "Make sure data is intact" );
|
||||
assert.equal( div.data( "test" ), undefined, "Make sure data is intact" );
|
||||
|
||||
div.removeData( "test.foo" );
|
||||
assert.equal( div.data( "test.foo" ), undefined, "Make sure data is intact" );
|
||||
} );
|
||||
|
||||
if ( window.JSON && window.JSON.stringify ) {
|
||||
QUnit.test( "JSON serialization (#8108)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var obj = { "foo": "bar" };
|
||||
jQuery.data( obj, "hidden", true );
|
||||
|
||||
assert.equal( JSON.stringify( obj ), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
|
||||
} );
|
||||
}
|
||||
|
||||
QUnit.test( ".data should follow html5 specification regarding camel casing", function( assert ) {
|
||||
assert.expect( 12 );
|
||||
|
||||
var div = jQuery( "<div id='myObject' data-w-t-f='ftw' data-big-a-little-a='bouncing-b' data-foo='a' data-foo-bar='b' data-foo-bar-baz='c'></div>" )
|
||||
.prependTo( "body" );
|
||||
|
||||
assert.equal( div.data()[ "wTF" ], "ftw", "Verify single letter data-* key" );
|
||||
assert.equal( div.data()[ "bigALittleA" ], "bouncing-b", "Verify single letter mixed data-* key" );
|
||||
|
||||
assert.equal( div.data()[ "foo" ], "a", "Verify single word data-* key" );
|
||||
assert.equal( div.data()[ "fooBar" ], "b", "Verify multiple word data-* key" );
|
||||
assert.equal( div.data()[ "fooBarBaz" ], "c", "Verify multiple word data-* key" );
|
||||
|
||||
assert.equal( div.data( "foo" ), "a", "Verify single word data-* key" );
|
||||
assert.equal( div.data( "fooBar" ), "b", "Verify multiple word data-* key" );
|
||||
assert.equal( div.data( "fooBarBaz" ), "c", "Verify multiple word data-* key" );
|
||||
|
||||
div.data( "foo-bar", "d" );
|
||||
|
||||
assert.equal( div.data( "fooBar" ), "d", "Verify updated data-* key" );
|
||||
assert.equal( div.data( "foo-bar" ), "d", "Verify updated data-* key" );
|
||||
|
||||
assert.equal( div.data( "fooBar" ), "d", "Verify updated data-* key (fooBar)" );
|
||||
assert.equal( div.data( "foo-bar" ), "d", "Verify updated data-* key (foo-bar)" );
|
||||
|
||||
div.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( ".data should not miss preset data-* w/ hyphenated property names", function( assert ) {
|
||||
|
||||
assert.expect( 2 );
|
||||
|
||||
var div = jQuery( "<div/>", { id: "hyphened" } ).appendTo( "#qunit-fixture" ),
|
||||
test = {
|
||||
"camelBar": "camelBar",
|
||||
"hyphen-foo": "hyphen-foo"
|
||||
};
|
||||
|
||||
div.data( test );
|
||||
|
||||
jQuery.each( test, function( i, k ) {
|
||||
assert.equal( div.data( k ), k, "data with property '" + k + "' was correctly found" );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.data should not miss data-* w/ hyphenated property names #14047", function( assert ) {
|
||||
|
||||
assert.expect( 1 );
|
||||
|
||||
var div = jQuery( "<div/>" );
|
||||
|
||||
div.data( "foo-bar", "baz" );
|
||||
|
||||
assert.equal( jQuery.data( div[ 0 ], "foo-bar" ), "baz", "data with property 'foo-bar' was correctly found" );
|
||||
} );
|
||||
|
||||
QUnit.test( ".data should not miss attr() set data-* with hyphenated property names", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var a, b;
|
||||
|
||||
a = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
a.attr( "data-long-param", "test" );
|
||||
a.data( "long-param", { a: 2 } );
|
||||
|
||||
assert.deepEqual( a.data( "long-param" ), { a: 2 }, "data with property long-param was found, 1" );
|
||||
|
||||
b = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
b.attr( "data-long-param", "test" );
|
||||
b.data( "long-param" );
|
||||
b.data( "long-param", { a: 2 } );
|
||||
|
||||
assert.deepEqual( b.data( "long-param" ), { a: 2 }, "data with property long-param was found, 2" );
|
||||
} );
|
||||
|
||||
QUnit.test( ".data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function( assert ) {
|
||||
var div = jQuery( "<div/>", { id: "hyphened" } ).appendTo( "#qunit-fixture" ),
|
||||
datas = {
|
||||
"non-empty": "a string",
|
||||
"empty-string": "",
|
||||
"one-value": 1,
|
||||
"zero-value": 0,
|
||||
"an-array": [],
|
||||
"an-object": {},
|
||||
"bool-true": true,
|
||||
"bool-false": false,
|
||||
|
||||
// JSHint enforces double quotes,
|
||||
// but JSON strings need double quotes to parse
|
||||
// so we need escaped double quotes here
|
||||
"some-json": "{ \"foo\": \"bar\" }",
|
||||
"num-1-middle": true,
|
||||
"num-end-2": true,
|
||||
"2-num-start": true
|
||||
};
|
||||
|
||||
assert.expect( 24 );
|
||||
|
||||
jQuery.each( datas, function( key, val ) {
|
||||
div.data( key, val );
|
||||
|
||||
assert.deepEqual( div.data( key ), val, "get: " + key );
|
||||
assert.deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( ".data supports interoperable removal of hyphenated/camelCase properties", function( assert ) {
|
||||
var div = jQuery( "<div/>", { id: "hyphened" } ).appendTo( "#qunit-fixture" ),
|
||||
datas = {
|
||||
"non-empty": "a string",
|
||||
"empty-string": "",
|
||||
"one-value": 1,
|
||||
"zero-value": 0,
|
||||
"an-array": [],
|
||||
"an-object": {},
|
||||
"bool-true": true,
|
||||
"bool-false": false,
|
||||
|
||||
// JSHint enforces double quotes,
|
||||
// but JSON strings need double quotes to parse
|
||||
// so we need escaped double quotes here
|
||||
"some-json": "{ \"foo\": \"bar\" }"
|
||||
};
|
||||
|
||||
assert.expect( 27 );
|
||||
|
||||
jQuery.each( datas, function( key, val ) {
|
||||
div.data( key, val );
|
||||
|
||||
assert.deepEqual( div.data( key ), val, "get: " + key );
|
||||
assert.deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
|
||||
|
||||
div.removeData( key );
|
||||
|
||||
assert.equal( div.data( key ), undefined, "get: " + key );
|
||||
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( ".data supports interoperable removal of properties SET TWICE #13850", function( assert ) {
|
||||
var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
|
||||
datas = {
|
||||
"non-empty": "a string",
|
||||
"empty-string": "",
|
||||
"one-value": 1,
|
||||
"zero-value": 0,
|
||||
"an-array": [],
|
||||
"an-object": {},
|
||||
"bool-true": true,
|
||||
"bool-false": false,
|
||||
|
||||
// JSHint enforces double quotes,
|
||||
// but JSON strings need double quotes to parse
|
||||
// so we need escaped double quotes here
|
||||
"some-json": "{ \"foo\": \"bar\" }"
|
||||
};
|
||||
|
||||
assert.expect( 9 );
|
||||
|
||||
jQuery.each( datas, function( key, val ) {
|
||||
div.data( key, val );
|
||||
div.data( key, val );
|
||||
|
||||
div.removeData( key );
|
||||
|
||||
assert.equal( div.data( key ), undefined, "removal: " + key );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( ".removeData supports removal of hyphenated properties via array (#12786)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var div, plain, compare;
|
||||
|
||||
div = jQuery( "<div>" ).appendTo( "#qunit-fixture" );
|
||||
plain = jQuery( {} );
|
||||
|
||||
// When data is batch assigned (via plain object), the properties
|
||||
// are not camel cased as they are with (property, value) calls
|
||||
compare = {
|
||||
|
||||
// From batch assignment .data({ "a-a": 1 })
|
||||
"a-a": 1,
|
||||
|
||||
// From property, value assignment .data( "b-b", 1 )
|
||||
"bB": 1
|
||||
};
|
||||
|
||||
// Mixed assignment
|
||||
div.data( { "a-a": 1 } ).data( "b-b", 1 );
|
||||
plain.data( { "a-a": 1 } ).data( "b-b", 1 );
|
||||
|
||||
assert.deepEqual( div.data(), compare, "Data appears as expected. (div)" );
|
||||
assert.deepEqual( plain.data(), compare, "Data appears as expected. (plain)" );
|
||||
|
||||
div.removeData( [ "a-a", "b-b" ] );
|
||||
plain.removeData( [ "a-a", "b-b" ] );
|
||||
|
||||
// NOTE: Timo's proposal for "propEqual" (or similar) would be nice here
|
||||
assert.deepEqual( div.data(), {}, "Data is empty. (div)" );
|
||||
assert.deepEqual( plain.data(), {}, "Data is empty. (plain)" );
|
||||
} );
|
||||
|
||||
// Test originally by Moschel
|
||||
QUnit.test( ".removeData should not throw exceptions. (#10080)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
QUnit.stop();
|
||||
var frame = jQuery( "#loadediframe" );
|
||||
jQuery( frame[ 0 ].contentWindow ).on( "unload", function() {
|
||||
assert.ok( true, "called unload" );
|
||||
QUnit.start();
|
||||
} );
|
||||
|
||||
// change the url to trigger unload
|
||||
frame.attr( "src", "data/iframe.html?param=true" );
|
||||
} );
|
||||
|
||||
QUnit.test( ".data only checks element attributes once. #8909", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var testing = {
|
||||
"test": "testing",
|
||||
"test2": "testing"
|
||||
},
|
||||
element = jQuery( "<div data-test='testing'>" ),
|
||||
node = element[ 0 ];
|
||||
|
||||
// set an attribute using attr to ensure it
|
||||
node.setAttribute( "data-test2", "testing" );
|
||||
assert.deepEqual( element.data(), testing, "Sanity Check" );
|
||||
|
||||
node.setAttribute( "data-test3", "testing" );
|
||||
assert.deepEqual( element.data(), testing, "The data didn't change even though the data-* attrs did" );
|
||||
|
||||
// clean up data cache
|
||||
element.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "data-* with JSON value can have newlines", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var x = jQuery( "<div data-some='{\n\"foo\":\n\t\"bar\"\n}'></div>" );
|
||||
assert.equal( x.data( "some" ).foo, "bar", "got a JSON data- attribute with spaces" );
|
||||
x.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( ".data doesn't throw when calling selection is empty. #13551", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
try {
|
||||
jQuery( null ).data( "prop" );
|
||||
assert.ok( true, "jQuery(null).data('prop') does not throw" );
|
||||
} catch ( e ) {
|
||||
assert.ok( false, e.message );
|
||||
}
|
||||
} );
|
||||
|
||||
QUnit.test( "acceptData", function( assert ) {
|
||||
assert.expect( 10 );
|
||||
|
||||
var flash, pdf, form;
|
||||
|
||||
assert.equal( jQuery( document ).data( "test", 42 ).data( "test" ), 42, "document" );
|
||||
assert.equal( jQuery( document.documentElement ).data( "test", 42 ).data( "test" ), 42, "documentElement" );
|
||||
assert.equal( jQuery( {} ).data( "test", 42 ).data( "test" ), 42, "object" );
|
||||
assert.equal( jQuery( document.createElement( "embed" ) ).data( "test", 42 ).data( "test" ), 42, "embed" );
|
||||
|
||||
flash = document.createElement( "object" );
|
||||
flash.setAttribute( "classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" );
|
||||
assert.equal( jQuery( flash ).data( "test", 42 ).data( "test" ), 42, "flash" );
|
||||
|
||||
pdf = document.createElement( "object" );
|
||||
pdf.setAttribute( "classid", "clsid:CA8A9780-280D-11CF-A24D-444553540000" );
|
||||
assert.equal( jQuery( pdf ).data( "test", 42 ).data( "test" ), 42, "pdf" );
|
||||
|
||||
assert.strictEqual( jQuery( document.createComment( "" ) ).data( "test", 42 ).data( "test" ), undefined, "comment" );
|
||||
assert.strictEqual( jQuery( document.createTextNode( "" ) ).data( "test", 42 ).data( "test" ), undefined, "text" );
|
||||
assert.strictEqual( jQuery( document.createDocumentFragment() ).data( "test", 42 ).data( "test" ), undefined, "documentFragment" );
|
||||
|
||||
form = jQuery( "#form" ).append( "<input id='nodeType'/><input id='nodeName'/>" )[ 0 ];
|
||||
assert.equal( jQuery( form ) .data( "test", 42 ).data( "test" ), 42, "form with aliased DOM properties" );
|
||||
} );
|
||||
|
||||
QUnit.test( "Check proper data removal of non-element descendants nodes (#8335)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var div = jQuery( "<div>text</div>" ),
|
||||
text = div.contents();
|
||||
|
||||
text.data( "test", "test" ); // This should be a noop.
|
||||
div.remove();
|
||||
|
||||
assert.ok( !text.data( "test" ), "Be sure data is not stored in non-element" );
|
||||
} );
|
||||
|
||||
testIframeWithCallback(
|
||||
"enumerate data attrs on body (#14894)",
|
||||
"data/dataAttrs.html",
|
||||
function( result, assert ) {
|
||||
assert.expect( 1 );
|
||||
assert.equal( result, "ok", "enumeration of data- attrs on body" );
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test( "Check that the expando is removed when there's no more data", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var key,
|
||||
div = jQuery( "<div/>" );
|
||||
div.data( "some", "data" );
|
||||
assert.equal( div.data( "some" ), "data", "Data is added" );
|
||||
div.removeData( "some" );
|
||||
|
||||
// Make sure the expando is gone
|
||||
for ( key in div[ 0 ] ) {
|
||||
if ( /^jQuery/.test( key ) ) {
|
||||
assert.strictEqual( div[ 0 ][ key ], undefined, "Expando was not removed when there was no more data" );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
QUnit.test( "Check that the expando is removed when there's no more data on non-nodes", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var key,
|
||||
obj = jQuery( { key: 42 } );
|
||||
obj.data( "some", "data" );
|
||||
assert.equal( obj.data( "some" ), "data", "Data is added" );
|
||||
obj.removeData( "some" );
|
||||
|
||||
// Make sure the expando is gone
|
||||
for ( key in obj[ 0 ] ) {
|
||||
if ( /^jQuery/.test( key ) ) {
|
||||
assert.ok( false, "Expando was not removed when there was no more data" );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
QUnit.test( ".data(prop) does not create expando", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var key,
|
||||
div = jQuery( "<div/>" );
|
||||
|
||||
div.data( "foo" );
|
||||
assert.equal( jQuery.hasData( div[ 0 ] ), false, "No data exists after access" );
|
||||
|
||||
// Make sure no expando has been added
|
||||
for ( key in div[ 0 ] ) {
|
||||
if ( /^jQuery/.test( key ) ) {
|
||||
assert.ok( false, "Expando was created on access" );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
QUnit.test( ".data(camelCase) retrieves hyphenated keys", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var div = jQuery( "<div/>" );
|
||||
|
||||
jQuery.data( div[ 0 ], "data-test", "data" );
|
||||
assert.equal( div.data( "dataTest" ), "data" );
|
||||
} );
|
447
dashboard-ui/bower_components/jquery/test/unit/deferred.js
vendored
Normal file
447
dashboard-ui/bower_components/jquery/test/unit/deferred.js
vendored
Normal file
|
@ -0,0 +1,447 @@
|
|||
QUnit.module( "deferred", {
|
||||
teardown: moduleTeardown
|
||||
} );
|
||||
|
||||
jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
|
||||
function createDeferred( fn ) {
|
||||
return withNew ? new jQuery.Deferred( fn ) : jQuery.Deferred( fn );
|
||||
}
|
||||
|
||||
QUnit.test( "jQuery.Deferred" + withNew, function( assert ) {
|
||||
|
||||
assert.expect( 23 );
|
||||
|
||||
var defer = createDeferred();
|
||||
|
||||
assert.strictEqual( defer.pipe, defer.then, "pipe is an alias of then" );
|
||||
|
||||
createDeferred().resolve().done( function() {
|
||||
assert.ok( true, "Success on resolve" );
|
||||
assert.strictEqual( this.state(), "resolved", "Deferred is resolved (state)" );
|
||||
} ).fail( function() {
|
||||
assert.ok( false, "Error on resolve" );
|
||||
} ).always( function() {
|
||||
assert.ok( true, "Always callback on resolve" );
|
||||
} );
|
||||
|
||||
createDeferred().reject().done( function() {
|
||||
assert.ok( false, "Success on reject" );
|
||||
} ).fail( function() {
|
||||
assert.ok( true, "Error on reject" );
|
||||
assert.strictEqual( this.state(), "rejected", "Deferred is rejected (state)" );
|
||||
} ).always( function() {
|
||||
assert.ok( true, "Always callback on reject" );
|
||||
} );
|
||||
|
||||
createDeferred( function( defer ) {
|
||||
assert.ok( this === defer, "Defer passed as this & first argument" );
|
||||
this.resolve( "done" );
|
||||
} ).done( function( value ) {
|
||||
assert.strictEqual( value, "done", "Passed function executed" );
|
||||
} );
|
||||
|
||||
createDeferred( function( defer ) {
|
||||
var promise = defer.promise(),
|
||||
func = function() {},
|
||||
funcPromise = defer.promise( func );
|
||||
assert.strictEqual( defer.promise(), promise, "promise is always the same" );
|
||||
assert.strictEqual( funcPromise, func, "non objects get extended" );
|
||||
jQuery.each( promise, function( key ) {
|
||||
if ( !jQuery.isFunction( promise[ key ] ) ) {
|
||||
assert.ok( false, key + " is a function (" + jQuery.type( promise[ key ] ) + ")" );
|
||||
}
|
||||
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 ) {
|
||||
assert.strictEqual( defer.state(), "pending", "pending after creation" );
|
||||
var checked = 0;
|
||||
defer.progress( function( value ) {
|
||||
assert.strictEqual( value, checked, "Progress: right value (" + value + ") received" );
|
||||
} );
|
||||
for ( checked = 0; checked < 3; checked++ ) {
|
||||
defer.notify( checked );
|
||||
}
|
||||
assert.strictEqual( defer.state(), "pending", "pending after notification" );
|
||||
defer[ change ]();
|
||||
assert.notStrictEqual( defer.state(), "pending", "not pending after " + change );
|
||||
defer.notify();
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred - chainability", function( assert ) {
|
||||
|
||||
var defer = jQuery.Deferred();
|
||||
|
||||
assert.expect( 10 );
|
||||
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
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 ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then( function( a, b ) {
|
||||
return a * b;
|
||||
} );
|
||||
|
||||
piped.done( function( result ) {
|
||||
value3 = result;
|
||||
} );
|
||||
|
||||
defer.done( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
} );
|
||||
|
||||
defer.resolve( 2, 3 );
|
||||
|
||||
assert.strictEqual( value1, 2, "first resolve value ok" );
|
||||
assert.strictEqual( value2, 3, "second resolve value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
|
||||
jQuery.Deferred().reject().then( function() {
|
||||
assert.ok( false, "then should not be called on reject" );
|
||||
} );
|
||||
|
||||
jQuery.Deferred().resolve().then( jQuery.noop ).done( function( value ) {
|
||||
assert.strictEqual( value, undefined, "then done callback can return undefined/null" );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - filtering (fail)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then( null, function( a, b ) {
|
||||
return a * b;
|
||||
} );
|
||||
|
||||
piped.fail( function( result ) {
|
||||
value3 = result;
|
||||
} );
|
||||
|
||||
defer.fail( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
} );
|
||||
|
||||
defer.reject( 2, 3 );
|
||||
|
||||
assert.strictEqual( value1, 2, "first reject value ok" );
|
||||
assert.strictEqual( value2, 3, "second reject value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
|
||||
jQuery.Deferred().resolve().then( null, function() {
|
||||
assert.ok( false, "then should not be called on resolve" );
|
||||
} );
|
||||
|
||||
jQuery.Deferred().reject().then( null, jQuery.noop ).fail( function( value ) {
|
||||
assert.strictEqual( value, undefined, "then fail callback can return undefined/null" );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - filtering (progress)", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then( null, null, function( a, b ) {
|
||||
return a * b;
|
||||
} );
|
||||
|
||||
piped.progress( function( result ) {
|
||||
value3 = result;
|
||||
} );
|
||||
|
||||
defer.progress( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
} );
|
||||
|
||||
defer.notify( 2, 3 );
|
||||
|
||||
assert.strictEqual( value1, 2, "first progress value ok" );
|
||||
assert.strictEqual( value2, 3, "second progress value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - deferred (done)", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then( function( a, b ) {
|
||||
return jQuery.Deferred( function( defer ) {
|
||||
defer.reject( a * b );
|
||||
} );
|
||||
} );
|
||||
|
||||
piped.fail( function( result ) {
|
||||
value3 = result;
|
||||
} );
|
||||
|
||||
defer.done( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
} );
|
||||
|
||||
defer.resolve( 2, 3 );
|
||||
|
||||
assert.strictEqual( value1, 2, "first resolve value ok" );
|
||||
assert.strictEqual( value2, 3, "second resolve value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - deferred (fail)", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then( null, function( a, b ) {
|
||||
return jQuery.Deferred( function( defer ) {
|
||||
defer.resolve( a * b );
|
||||
} );
|
||||
} );
|
||||
|
||||
piped.done( function( result ) {
|
||||
value3 = result;
|
||||
} );
|
||||
|
||||
defer.fail( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
} );
|
||||
|
||||
defer.reject( 2, 3 );
|
||||
|
||||
assert.strictEqual( value1, 2, "first reject value ok" );
|
||||
assert.strictEqual( value2, 3, "second reject value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - deferred (progress)", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var value1, value2, value3,
|
||||
defer = jQuery.Deferred(),
|
||||
piped = defer.then( null, null, function( a, b ) {
|
||||
return jQuery.Deferred( function( defer ) {
|
||||
defer.resolve( a * b );
|
||||
} );
|
||||
} );
|
||||
piped.done( function( result ) {
|
||||
value3 = result;
|
||||
} );
|
||||
|
||||
defer.progress( function( a, b ) {
|
||||
value1 = a;
|
||||
value2 = b;
|
||||
} );
|
||||
|
||||
defer.notify( 2, 3 );
|
||||
|
||||
assert.strictEqual( value1, 2, "first progress value ok" );
|
||||
assert.strictEqual( value2, 3, "second progress value ok" );
|
||||
assert.strictEqual( value3, 6, "result of filter ok" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.Deferred.then - context", function( assert ) {
|
||||
assert.expect( 7 );
|
||||
|
||||
var defer, piped, defer2, piped2,
|
||||
context = {};
|
||||
|
||||
jQuery.Deferred().resolveWith( context, [ 2 ] ).then( function( value ) {
|
||||
return value * 3;
|
||||
} ).done( function( value ) {
|
||||
assert.strictEqual( this, context, "custom context correctly propagated" );
|
||||
assert.strictEqual( value, 6, "proper value received" );
|
||||
} );
|
||||
|
||||
jQuery.Deferred().resolve().then( function() {
|
||||
return jQuery.Deferred().resolveWith( context );
|
||||
} ).done( function() {
|
||||
assert.strictEqual( this, context, "custom context of returned deferred correctly propagated" );
|
||||
} );
|
||||
|
||||
defer = jQuery.Deferred();
|
||||
piped = defer.then( function( value ) {
|
||||
return value * 3;
|
||||
} );
|
||||
|
||||
defer.resolve( 2 );
|
||||
|
||||
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" );
|
||||
} );
|
||||
defer2 = jQuery.Deferred();
|
||||
piped2 = defer2.then();
|
||||
|
||||
defer2.resolve( 2 );
|
||||
|
||||
piped2.done( function( value ) {
|
||||
assert.strictEqual( this, piped2, "default context gets updated to latest promise in the chain (without passing function)" );
|
||||
assert.strictEqual( value, 2, "proper value received (without passing function)" );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.when", function( assert ) {
|
||||
assert.expect( 37 );
|
||||
|
||||
jQuery.each( {
|
||||
"an empty string": "",
|
||||
"a non-empty string": "some string",
|
||||
"zero": 0,
|
||||
"a number other than zero": 1,
|
||||
"true": true,
|
||||
"false": false,
|
||||
"null": null,
|
||||
"undefined": undefined,
|
||||
"a plain object": {},
|
||||
"an array": [ 1, 2, 3 ]
|
||||
|
||||
}, function( message, value ) {
|
||||
assert.ok(
|
||||
jQuery.isFunction(
|
||||
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
|
||||
),
|
||||
"Test " + message + " triggers the creation of a new Promise"
|
||||
);
|
||||
} );
|
||||
|
||||
assert.ok(
|
||||
jQuery.isFunction(
|
||||
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
|
||||
),
|
||||
"Test calling when with no parameter triggers the creation of a new Promise"
|
||||
);
|
||||
|
||||
var cache,
|
||||
context = {};
|
||||
|
||||
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.when( cache || jQuery.Deferred( function() {
|
||||
this.resolve( i );
|
||||
} )
|
||||
).done( function( value ) {
|
||||
|
||||
assert.strictEqual( value, 1, "Function executed" + ( i > 1 ? " only once" : "" ) );
|
||||
cache = value;
|
||||
} );
|
||||
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.when - joined", function( assert ) {
|
||||
assert.expect( 119 );
|
||||
|
||||
var deferreds = {
|
||||
value: 1,
|
||||
success: jQuery.Deferred().resolve( 1 ),
|
||||
error: jQuery.Deferred().reject( 0 ),
|
||||
futureSuccess: jQuery.Deferred().notify( true ),
|
||||
futureError: jQuery.Deferred().notify( true ),
|
||||
notify: jQuery.Deferred().notify( true )
|
||||
},
|
||||
willSucceed = {
|
||||
value: true,
|
||||
success: true,
|
||||
futureSuccess: true
|
||||
},
|
||||
willError = {
|
||||
error: true,
|
||||
futureError: true
|
||||
},
|
||||
willNotify = {
|
||||
futureSuccess: true,
|
||||
futureError: true,
|
||||
notify: true
|
||||
};
|
||||
|
||||
jQuery.each( deferreds, function( id1, defer1 ) {
|
||||
jQuery.each( deferreds, function( id2, defer2 ) {
|
||||
var shouldResolve = willSucceed[ id1 ] && willSucceed[ id2 ],
|
||||
shouldError = willError[ id1 ] || willError[ id2 ],
|
||||
shouldNotify = willNotify[ id1 ] || willNotify[ id2 ],
|
||||
expected = shouldResolve ? [ 1, 1 ] : [ 0, undefined ],
|
||||
expectedNotify = shouldNotify && [ willNotify[ id1 ], willNotify[ id2 ] ],
|
||||
code = id1 + "/" + id2,
|
||||
context1 = defer1 && jQuery.isFunction( defer1.promise ) ? defer1.promise() : undefined,
|
||||
context2 = defer2 && jQuery.isFunction( defer2.promise ) ? defer2.promise() : undefined;
|
||||
|
||||
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" );
|
||||
assert.strictEqual( this[ 1 ], context2, code + " => second context OK" );
|
||||
} else {
|
||||
assert.ok( false, code + " => resolve" );
|
||||
}
|
||||
} ).fail( function( a, b ) {
|
||||
if ( shouldError ) {
|
||||
assert.deepEqual( [ a, b ], expected, code + " => reject" );
|
||||
} else {
|
||||
assert.ok( false, code + " => reject" );
|
||||
}
|
||||
} ).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" );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
deferreds.futureSuccess.resolve( 1 );
|
||||
deferreds.futureError.reject( 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.when - resolved", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var a = jQuery.Deferred().notify( 1 ).resolve( 4 ),
|
||||
b = jQuery.Deferred().notify( 2 ).resolve( 5 ),
|
||||
c = jQuery.Deferred().notify( 3 ).resolve( 6 );
|
||||
|
||||
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 ) {
|
||||
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() {
|
||||
assert.ok( false, "Error on resolve" );
|
||||
} );
|
||||
|
||||
} );
|
47
dashboard-ui/bower_components/jquery/test/unit/deprecated.js
vendored
Normal file
47
dashboard-ui/bower_components/jquery/test/unit/deprecated.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
QUnit.module( "deprecated", { teardown: moduleTeardown } );
|
||||
|
||||
QUnit.test( "bind/unbind", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var markup = jQuery(
|
||||
"<div><p><span><b>b</b></span></p></div>"
|
||||
);
|
||||
|
||||
markup
|
||||
.find( "b" )
|
||||
.bind( "click", { bindData: 19 }, function( e, trig ) {
|
||||
assert.equal( e.type, "click", "correct event type" );
|
||||
assert.equal( e.data.bindData, 19, "correct trigger data" );
|
||||
assert.equal( trig, 42, "correct bind data" );
|
||||
assert.equal( e.target.nodeName.toLowerCase(), "b", "correct element" );
|
||||
} )
|
||||
.trigger( "click", [ 42 ] )
|
||||
.unbind( "click" )
|
||||
.trigger( "click" )
|
||||
.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "delegate/undelegate", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var markup = jQuery(
|
||||
"<div><p><span><b>b</b></span></p></div>"
|
||||
);
|
||||
|
||||
markup
|
||||
.delegate( "b", "click", function( e ) {
|
||||
assert.equal( e.type, "click", "correct event type" );
|
||||
assert.equal( e.target.nodeName.toLowerCase(), "b", "correct element" );
|
||||
} )
|
||||
.find( "b" )
|
||||
.trigger( "click" )
|
||||
.end()
|
||||
.undelegate( "b", "click" )
|
||||
.remove();
|
||||
} );
|
||||
if ( jQuery.fn.size ) {
|
||||
QUnit.test("size()", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
assert.equal( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" );
|
||||
});
|
||||
}
|
476
dashboard-ui/bower_components/jquery/test/unit/dimensions.js
vendored
Normal file
476
dashboard-ui/bower_components/jquery/test/unit/dimensions.js
vendored
Normal file
|
@ -0,0 +1,476 @@
|
|||
( function() {
|
||||
|
||||
if ( !jQuery.fn.width ) {
|
||||
return;
|
||||
}
|
||||
|
||||
QUnit.module( "dimensions", { teardown: moduleTeardown } );
|
||||
|
||||
function pass( val ) {
|
||||
return val;
|
||||
}
|
||||
|
||||
function fn( val ) {
|
||||
return function() {
|
||||
return val;
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
======== local reference =======
|
||||
pass and fn can be used to test passing functions to setters
|
||||
See testWidth below for an example
|
||||
|
||||
pass( value, assert );
|
||||
This function returns whatever value is passed in
|
||||
|
||||
fn( value, assert );
|
||||
Returns a function that returns the value
|
||||
*/
|
||||
|
||||
function testWidth( val, assert ) {
|
||||
assert.expect( 9 );
|
||||
var $div, blah;
|
||||
|
||||
$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" );
|
||||
$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.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": "" } );
|
||||
|
||||
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." );
|
||||
}
|
||||
|
||||
QUnit.test( "width()", function( assert ) {
|
||||
testWidth( pass, assert );
|
||||
} );
|
||||
|
||||
QUnit.test( "width(Function)", function( assert ) {
|
||||
testWidth( fn, assert );
|
||||
} );
|
||||
|
||||
QUnit.test( "width(Function(args))", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
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 );
|
||||
|
||||
var $div, blah;
|
||||
|
||||
$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" );
|
||||
$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.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": "" } );
|
||||
|
||||
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." );
|
||||
}
|
||||
|
||||
QUnit.test( "height()", function( assert ) {
|
||||
testHeight( pass, assert );
|
||||
} );
|
||||
|
||||
QUnit.test( "height(Function)", function( assert ) {
|
||||
testHeight( fn, assert );
|
||||
} );
|
||||
|
||||
QUnit.test( "height(Function(args))", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
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 ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var $div, div,
|
||||
$win = jQuery( window ),
|
||||
$doc = jQuery( document );
|
||||
|
||||
assert.equal( jQuery( window ).innerWidth(), $win.width(), "Test on window" );
|
||||
assert.equal( jQuery( document ).innerWidth(), $doc.width(), "Test on document" );
|
||||
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.css( {
|
||||
"margin": 10,
|
||||
"border": "2px solid #fff",
|
||||
"width": 30
|
||||
} );
|
||||
|
||||
assert.equal( $div.innerWidth(), 30, "Test with margin and border" );
|
||||
$div.css( "padding", "20px" );
|
||||
assert.equal( $div.innerWidth(), 70, "Test with margin, border and padding" );
|
||||
$div.hide();
|
||||
assert.equal( $div.innerWidth(), 70, "Test hidden div" );
|
||||
|
||||
// reset styles
|
||||
$div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } );
|
||||
|
||||
div = jQuery( "<div>" );
|
||||
|
||||
// Temporarily require 0 for backwards compat - should be auto
|
||||
assert.equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "innerHeight()", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var $div, div,
|
||||
$win = jQuery( window ),
|
||||
$doc = jQuery( document );
|
||||
|
||||
assert.equal( jQuery( window ).innerHeight(), $win.height(), "Test on window" );
|
||||
assert.equal( jQuery( document ).innerHeight(), $doc.height(), "Test on document" );
|
||||
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.css( {
|
||||
"margin": 10,
|
||||
"border": "2px solid #fff",
|
||||
"height": 30
|
||||
} );
|
||||
|
||||
assert.equal( $div.innerHeight(), 30, "Test with margin and border" );
|
||||
$div.css( "padding", "20px" );
|
||||
assert.equal( $div.innerHeight(), 70, "Test with margin, border and padding" );
|
||||
$div.hide();
|
||||
assert.equal( $div.innerHeight(), 70, "Test hidden div" );
|
||||
|
||||
// reset styles
|
||||
$div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } );
|
||||
|
||||
div = jQuery( "<div>" );
|
||||
|
||||
// Temporarily require 0 for backwards compat - should be auto
|
||||
assert.equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "outerWidth()", function( assert ) {
|
||||
assert.expect( 11 );
|
||||
|
||||
var $div, div,
|
||||
$win = jQuery( window ),
|
||||
$doc = jQuery( document );
|
||||
|
||||
assert.equal( jQuery( window ).outerWidth(), $win.width(), "Test on window without margin option" );
|
||||
assert.equal( jQuery( window ).outerWidth( true ), $win.width(), "Test on window with margin option" );
|
||||
assert.equal( jQuery( document ).outerWidth(), $doc.width(), "Test on document without margin option" );
|
||||
assert.equal( jQuery( document ).outerWidth( true ), $doc.width(), "Test on document with margin option" );
|
||||
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.css( "width", 30 );
|
||||
|
||||
assert.equal( $div.outerWidth(), 30, "Test with only width set" );
|
||||
$div.css( "padding", "20px" );
|
||||
assert.equal( $div.outerWidth(), 70, "Test with padding" );
|
||||
$div.css( "border", "2px solid #fff" );
|
||||
assert.equal( $div.outerWidth(), 74, "Test with padding and border" );
|
||||
$div.css( "margin", "10px" );
|
||||
assert.equal( $div.outerWidth(), 74, "Test with padding, border and margin without margin option" );
|
||||
$div.css( "position", "absolute" );
|
||||
assert.equal( $div.outerWidth( true ), 94, "Test with padding, border and margin with margin option" );
|
||||
$div.hide();
|
||||
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 = jQuery( "<div>" );
|
||||
|
||||
// Temporarily require 0 for backwards compat - should be auto
|
||||
assert.equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
} );
|
||||
|
||||
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" } ),
|
||||
$divChild = $divNormal.clone(),
|
||||
$divUnconnected = $divNormal.clone(),
|
||||
$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.height(), $divNormal.height(), "child of a hidden element height() is wrong see #9441" );
|
||||
assert.equal( $divChild.innerHeight(), $divNormal.innerHeight(), "child of a hidden element innerHeight() is wrong see #9441" );
|
||||
assert.equal( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #9441" );
|
||||
assert.equal( $divChild.outerHeight( true ), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #9300" );
|
||||
|
||||
// tests that child div of an unconnected div works the same as a normal div
|
||||
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.height(), $divNormal.height(), "unconnected element height() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.innerHeight(), $divNormal.innerHeight(), "unconnected element innerHeight() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.outerHeight(), $divNormal.outerHeight(), "unconnected element outerHeight() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.outerHeight( true ), $divNormal.outerHeight( true ), "unconnected element outerHeight( true ) is wrong see #9300" );
|
||||
|
||||
// teardown html
|
||||
$divHiddenParent.remove();
|
||||
$divNormal.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "getting dimensions shouldn't modify runtimeStyle see #9233", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
|
||||
div = $div.get( 0 ),
|
||||
runtimeStyle = div.runtimeStyle;
|
||||
|
||||
if ( runtimeStyle ) {
|
||||
div.runtimeStyle.marginLeft = "12em";
|
||||
div.runtimeStyle.left = "11em";
|
||||
}
|
||||
|
||||
$div.outerWidth( true );
|
||||
|
||||
if ( runtimeStyle ) {
|
||||
assert.equal( div.runtimeStyle.left, "11em", "getting dimensions modifies runtimeStyle, see #9233" );
|
||||
} else {
|
||||
assert.ok( true, "this browser doesn't support runtimeStyle, see #9233" );
|
||||
}
|
||||
|
||||
$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 );
|
||||
|
||||
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 );
|
||||
|
||||
// setup html
|
||||
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" );
|
||||
|
||||
// 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.height(), $divNormal.height(), "child of a hidden element height() is wrong see #10413" );
|
||||
assert.equal( $divChild.innerHeight(), $divNormal.innerHeight(), "child of a hidden element innerHeight() is wrong see #10413" );
|
||||
assert.equal( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #10413" );
|
||||
assert.equal( $divChild.outerHeight( true ), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #10413" );
|
||||
|
||||
// tests that child div of an unconnected div works the same as a normal div
|
||||
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.height(), $divNormal.height(), "unconnected element height() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.innerHeight(), $divNormal.innerHeight(), "unconnected element innerHeight() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.outerHeight(), $divNormal.outerHeight(), "unconnected element outerHeight() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.outerHeight( true ), $divNormal.outerHeight( true ), "unconnected element outerHeight( true ) is wrong see #10413" );
|
||||
|
||||
// teardown html
|
||||
$divHiddenParent.remove();
|
||||
$divNormal.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "outerHeight()", function( assert ) {
|
||||
assert.expect( 11 );
|
||||
|
||||
var $div, div,
|
||||
$win = jQuery( window ),
|
||||
$doc = jQuery( document );
|
||||
|
||||
assert.equal( jQuery( window ).outerHeight(), $win.height(), "Test on window without margin option" );
|
||||
assert.equal( jQuery( window ).outerHeight( true ), $win.height(), "Test on window with margin option" );
|
||||
assert.equal( jQuery( document ).outerHeight(), $doc.height(), "Test on document without margin option" );
|
||||
assert.equal( jQuery( document ).outerHeight( true ), $doc.height(), "Test on document with margin option" );
|
||||
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.css( "height", 30 );
|
||||
|
||||
assert.equal( $div.outerHeight(), 30, "Test with only width set" );
|
||||
$div.css( "padding", "20px" );
|
||||
assert.equal( $div.outerHeight(), 70, "Test with padding" );
|
||||
$div.css( "border", "2px solid #fff" );
|
||||
assert.equal( $div.outerHeight(), 74, "Test with padding and border" );
|
||||
$div.css( "margin", "10px" );
|
||||
assert.equal( $div.outerHeight(), 74, "Test with padding, border and margin without margin option" );
|
||||
assert.equal( $div.outerHeight( true ), 94, "Test with padding, border and margin with margin option" );
|
||||
$div.hide();
|
||||
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 = jQuery( "<div>" );
|
||||
|
||||
// Temporarily require 0 for backwards compat - should be auto
|
||||
assert.equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
} );
|
||||
|
||||
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" );
|
||||
|
||||
assert.strictEqual( nonElem.width(), null, ".width() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.innerWidth(), null, ".innerWidth() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.outerWidth(), null, ".outerWidth() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.outerWidth( true ), null, ".outerWidth(true) is not null (#12283)" );
|
||||
|
||||
assert.strictEqual( nonElem.height(), null, ".height() is not null (#12283)" );
|
||||
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( 60 );
|
||||
|
||||
// Support: Firefox<29, Android 2.3 (Prefixed box-sizing versions).
|
||||
var parent = jQuery( "#foo" ).css( { width: "200px", height: "200px", "font-size": "16px" } ),
|
||||
el_bb = jQuery( "<div style='margin:5px;padding:1px;border:2px solid black;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;'></div>" ).appendTo( parent ),
|
||||
el = jQuery( "<div style='margin:5px;padding:1px;border:2px solid black;'></div>" ).appendTo( parent );
|
||||
|
||||
jQuery.each( {
|
||||
"number": { set: 100, expected: 100 },
|
||||
"em": { set: "10em", expected: 160 },
|
||||
"percentage": { set: "50%", expected: 100 }
|
||||
}, function( units, values ) {
|
||||
assert.equal( el_bb.width( values.set ).width(), values.expected, "test border-box width(" + units + ") by roundtripping" );
|
||||
assert.equal( el_bb.innerWidth( values.set ).width(), values.expected - 2, "test border-box innerWidth(" + units + ") by roundtripping" );
|
||||
assert.equal( el_bb.outerWidth( values.set ).width(), values.expected - 6, "test border-box outerWidth(" + units + ") by roundtripping" );
|
||||
assert.equal( el_bb.outerWidth( values.set, false ).width(), values.expected - 6, "test border-box outerWidth(" + units + ", false) by roundtripping" );
|
||||
assert.equal( el_bb.outerWidth( values.set, true ).width(), values.expected - 16, "test border-box innerWidth(" + units + ", true) by roundtripping" );
|
||||
|
||||
assert.equal( el_bb.height( values.set ).height(), values.expected, "test border-box height(" + units + ") by roundtripping" );
|
||||
assert.equal( el_bb.innerHeight( values.set ).height(), values.expected - 2, "test border-box innerHeight(" + units + ") by roundtripping" );
|
||||
assert.equal( el_bb.outerHeight( values.set ).height(), values.expected - 6, "test border-box outerHeight(" + units + ") by roundtripping" );
|
||||
assert.equal( el_bb.outerHeight( values.set, false ).height(), values.expected - 6, "test border-box outerHeight(" + units + ", false) by roundtripping" );
|
||||
assert.equal( el_bb.outerHeight( values.set, true ).height(), values.expected - 16, "test border-box innerHeight(" + units + ", true) by roundtripping" );
|
||||
|
||||
assert.equal( el.width( values.set ).width(), values.expected, "test non-border-box width(" + units + ") by roundtripping" );
|
||||
assert.equal( el.innerWidth( values.set ).width(), values.expected - 2, "test non-border-box innerWidth(" + units + ") by roundtripping" );
|
||||
assert.equal( el.outerWidth( values.set ).width(), values.expected - 6, "test non-border-box outerWidth(" + units + ") by roundtripping" );
|
||||
assert.equal( el.outerWidth( values.set, false ).width(), values.expected - 6, "test non-border-box outerWidth(" + units + ", false) by roundtripping" );
|
||||
assert.equal( el.outerWidth( values.set, true ).width(), values.expected - 16, "test non-border-box innerWidth(" + units + ", true) by roundtripping" );
|
||||
|
||||
assert.equal( el.height( values.set ).height(), values.expected, "test non-border-box height(" + units + ") by roundtripping" );
|
||||
assert.equal( el.innerHeight( values.set ).height(), values.expected - 2, "test non-border-box innerHeight(" + units + ") by roundtripping" );
|
||||
assert.equal( el.outerHeight( values.set ).height(), values.expected - 6, "test non-border-box outerHeight(" + units + ") by roundtripping" );
|
||||
assert.equal( el.outerHeight( values.set, false ).height(), values.expected - 6, "test non-border-box outerHeight(" + units + ", false) by roundtripping" );
|
||||
assert.equal( el.outerHeight( values.set, true ).height(), values.expected - 16, "test non-border-box innerHeight(" + units + ", true) by roundtripping" );
|
||||
} );
|
||||
} );
|
||||
|
||||
testIframe(
|
||||
"dimensions/documentLarge",
|
||||
"window vs. large document",
|
||||
function( jQuery, window, document, assert ) {
|
||||
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" );
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test( "allow modification of coordinates argument (gh-1848)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var offsetTop,
|
||||
element = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
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 + ")" );
|
||||
} );
|
||||
|
||||
} )();
|
2392
dashboard-ui/bower_components/jquery/test/unit/effects.js
vendored
Normal file
2392
dashboard-ui/bower_components/jquery/test/unit/effects.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
3015
dashboard-ui/bower_components/jquery/test/unit/event.js
vendored
Normal file
3015
dashboard-ui/bower_components/jquery/test/unit/event.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
7
dashboard-ui/bower_components/jquery/test/unit/exports.js
vendored
Normal file
7
dashboard-ui/bower_components/jquery/test/unit/exports.js
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
QUnit.module( "exports", { teardown: moduleTeardown } );
|
||||
|
||||
QUnit.test( "amdModule", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
assert.equal( jQuery, amdDefined, "Make sure defined module matches jQuery" );
|
||||
} );
|
2661
dashboard-ui/bower_components/jquery/test/unit/manipulation.js
vendored
Normal file
2661
dashboard-ui/bower_components/jquery/test/unit/manipulation.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
616
dashboard-ui/bower_components/jquery/test/unit/offset.js
vendored
Normal file
616
dashboard-ui/bower_components/jquery/test/unit/offset.js
vendored
Normal file
|
@ -0,0 +1,616 @@
|
|||
( function() {
|
||||
|
||||
if ( !jQuery.fn.offset ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var supportsScroll, supportsFixedPosition,
|
||||
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" );
|
||||
|
||||
// Must append to body because #qunit-fixture is hidden and elements inside it don't have a scrollTop
|
||||
forceScroll.appendTo( "body" );
|
||||
window.scrollTo( 200, 200 );
|
||||
supportsScroll = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
forceScroll.detach();
|
||||
|
||||
supportsFixedPosition = checkFixed[ 0 ].offsetTop === 20;
|
||||
checkFixed.remove();
|
||||
};
|
||||
|
||||
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" );
|
||||
window.scrollTo( 1, 1 );
|
||||
forceScroll.detach();
|
||||
}, teardown: moduleTeardown } );
|
||||
|
||||
/*
|
||||
Closure-compiler will roll static methods off of the jQuery object and so they will
|
||||
not be passed with the jQuery object across the windows. To differentiate this, the
|
||||
testIframe callbacks use the "$" symbol to refer to the jQuery object passed from
|
||||
the iframe window and the "jQuery" symbol is used to access any static methods.
|
||||
*/
|
||||
|
||||
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( "object without getBoundingClientRect", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
// Simulates a browser without gBCR on elements, we just want to return 0,0
|
||||
var result = jQuery( { ownerDocument: document } ).offset();
|
||||
assert.equal( result.top, 0, "Check top" );
|
||||
assert.equal( result.left, 0, "Check left" );
|
||||
} );
|
||||
|
||||
QUnit.test( "disconnected node", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var result = jQuery( document.createElement( "div" ) ).offset();
|
||||
|
||||
// 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( result.top, 0, "Check top" );
|
||||
assert.equal( result.left, 0, "Check left" );
|
||||
} );
|
||||
|
||||
QUnit.test( "hidden (display: none) element", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var node = jQuery( "<div style='display: none' />" ).appendTo( "#qunit-fixture" ),
|
||||
result = node.offset();
|
||||
|
||||
node.remove();
|
||||
|
||||
// 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( 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 );
|
||||
|
||||
var doc = iframe.document,
|
||||
tests;
|
||||
|
||||
// get offset
|
||||
tests = [
|
||||
{ "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" );
|
||||
} );
|
||||
|
||||
// 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" );
|
||||
} );
|
||||
} );
|
||||
|
||||
testIframe( "offset/absolute", "absolute", function( $, window, document, assert ) {
|
||||
assert.expect( 178 );
|
||||
|
||||
var tests, offset;
|
||||
|
||||
// get offset tests
|
||||
tests = [
|
||||
{ "id": "#absolute-1", "top": 1, "left": 1 },
|
||||
{ "id": "#absolute-1-1", "top": 5, "left": 5 },
|
||||
{ "id": "#absolute-1-1-1", "top": 9, "left": 9 },
|
||||
{ "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" );
|
||||
} );
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ "id": "#absolute-1", "top": 0, "left": 0 },
|
||||
{ "id": "#absolute-1-1", "top": 1, "left": 1 },
|
||||
{ "id": "#absolute-1-1-1", "top": 1, "left": 1 },
|
||||
{ "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" );
|
||||
} );
|
||||
|
||||
// test #5781
|
||||
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 },
|
||||
{ "id": "#absolute-2", "top": 10, "left": 10 },
|
||||
{ "id": "#absolute-2", "top": -1, "left": -1 },
|
||||
{ "id": "#absolute-2", "top": 19, "left": 19 },
|
||||
{ "id": "#absolute-1-1-1", "top": 15, "left": 15 },
|
||||
{ "id": "#absolute-1-1-1", "top": 5, "left": 5 },
|
||||
{ "id": "#absolute-1-1-1", "top": -1, "left": -1 },
|
||||
{ "id": "#absolute-1-1-1", "top": 9, "left": 9 },
|
||||
{ "id": "#absolute-1-1", "top": 10, "left": 10 },
|
||||
{ "id": "#absolute-1-1", "top": 0, "left": 0 },
|
||||
{ "id": "#absolute-1-1", "top": -1, "left": -1 },
|
||||
{ "id": "#absolute-1-1", "top": 5, "left": 5 },
|
||||
{ "id": "#absolute-1", "top": 2, "left": 2 },
|
||||
{ "id": "#absolute-1", "top": 0, "left": 0 },
|
||||
{ "id": "#absolute-1", "top": -1, "left": -1 },
|
||||
{ "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" ] + " })" );
|
||||
|
||||
var top = this[ "top" ], left = this[ "left" ];
|
||||
|
||||
$( 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 ) + " })" );
|
||||
|
||||
$( 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( {
|
||||
"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 })" );
|
||||
} );
|
||||
} );
|
||||
|
||||
testIframe( "offset/relative", "relative", function( $, window, document, assert ) {
|
||||
assert.expect( 64 );
|
||||
|
||||
// get offset
|
||||
var tests = [
|
||||
{ "id": "#relative-1", "top": 7, "left": 7 },
|
||||
{ "id": "#relative-1-1", "top": 15, "left": 15 },
|
||||
{ "id": "#relative-2", "top": 142, "left": 27 },
|
||||
{ "id": "#relative-2-1", "top": 149, "left": 52 }
|
||||
];
|
||||
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" );
|
||||
} );
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ "id": "#relative-1", "top": 6, "left": 6 },
|
||||
{ "id": "#relative-1-1", "top": 5, "left": 5 },
|
||||
{ "id": "#relative-2", "top": 141, "left": 26 },
|
||||
{ "id": "#relative-2-1", "top": 5, "left": 5 }
|
||||
];
|
||||
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" );
|
||||
} );
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
{ "id": "#relative-2", "top": 200, "left": 50 },
|
||||
{ "id": "#relative-2", "top": 100, "left": 10 },
|
||||
{ "id": "#relative-2", "top": -5, "left": -5 },
|
||||
{ "id": "#relative-2", "top": 142, "left": 27 },
|
||||
{ "id": "#relative-1-1", "top": 100, "left": 100 },
|
||||
{ "id": "#relative-1-1", "top": 5, "left": 5 },
|
||||
{ "id": "#relative-1-1", "top": -1, "left": -1 },
|
||||
{ "id": "#relative-1-1", "top": 15, "left": 15 },
|
||||
{ "id": "#relative-1", "top": 100, "left": 100 },
|
||||
{ "id": "#relative-1", "top": 0, "left": 0 },
|
||||
{ "id": "#relative-1", "top": -1, "left": -1 },
|
||||
{ "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" ], "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 })" );
|
||||
} );
|
||||
} );
|
||||
|
||||
testIframe( "offset/static", "static", function( $, window, document, assert ) {
|
||||
assert.expect( 80 );
|
||||
|
||||
// get offset
|
||||
var tests = [
|
||||
{ "id": "#static-1", "top": 7, "left": 7 },
|
||||
{ "id": "#static-1-1", "top": 15, "left": 15 },
|
||||
{ "id": "#static-1-1-1", "top": 23, "left": 23 },
|
||||
{ "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" );
|
||||
} );
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ "id": "#static-1", "top": 6, "left": 6 },
|
||||
{ "id": "#static-1-1", "top": 14, "left": 14 },
|
||||
{ "id": "#static-1-1-1", "top": 22, "left": 22 },
|
||||
{ "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" );
|
||||
} );
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
{ "id": "#static-2", "top": 200, "left": 200 },
|
||||
{ "id": "#static-2", "top": 100, "left": 100 },
|
||||
{ "id": "#static-2", "top": -2, "left": -2 },
|
||||
{ "id": "#static-2", "top": 121, "left": 6 },
|
||||
{ "id": "#static-1-1-1", "top": 50, "left": 50 },
|
||||
{ "id": "#static-1-1-1", "top": 10, "left": 10 },
|
||||
{ "id": "#static-1-1-1", "top": -1, "left": -1 },
|
||||
{ "id": "#static-1-1-1", "top": 22, "left": 22 },
|
||||
{ "id": "#static-1-1", "top": 25, "left": 25 },
|
||||
{ "id": "#static-1-1", "top": 10, "left": 10 },
|
||||
{ "id": "#static-1-1", "top": -3, "left": -3 },
|
||||
{ "id": "#static-1-1", "top": 14, "left": 14 },
|
||||
{ "id": "#static-1", "top": 30, "left": 30 },
|
||||
{ "id": "#static-1", "top": 2, "left": 2 },
|
||||
{ "id": "#static-1", "top": -2, "left": -2 },
|
||||
{ "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" ], "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 })" );
|
||||
} );
|
||||
} );
|
||||
|
||||
testIframe( "offset/fixed", "fixed", function( $, window, document, assert ) {
|
||||
assert.expect( 34 );
|
||||
|
||||
var tests, $noTopLeft;
|
||||
|
||||
tests = [
|
||||
{
|
||||
"id": "#fixed-1",
|
||||
"offsetTop": 1001,
|
||||
"offsetLeft": 1001,
|
||||
"positionTop": 0,
|
||||
"positionLeft": 0
|
||||
},
|
||||
{
|
||||
"id": "#fixed-2",
|
||||
"offsetTop": 1021,
|
||||
"offsetLeft": 1021,
|
||||
"positionTop": 20,
|
||||
"positionLeft": 20
|
||||
}
|
||||
];
|
||||
|
||||
jQuery.each( tests, function() {
|
||||
if ( !window.supportsScroll ) {
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
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" );
|
||||
} 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 },
|
||||
{ "id": "#fixed-1", "top": 0, "left": 0 },
|
||||
{ "id": "#fixed-1", "top": -4, "left": -4 },
|
||||
{ "id": "#fixed-2", "top": 200, "left": 200 },
|
||||
{ "id": "#fixed-2", "top": 0, "left": 0 },
|
||||
{ "id": "#fixed-2", "top": -5, "left": -5 }
|
||||
];
|
||||
|
||||
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" ], "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 })" );
|
||||
} 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" );
|
||||
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 );
|
||||
|
||||
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" );
|
||||
} );
|
||||
|
||||
testIframe( "offset/scroll", "scroll", function( $, win, doc, assert ) {
|
||||
assert.expect( 28 );
|
||||
|
||||
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" );
|
||||
|
||||
// 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" );
|
||||
|
||||
// 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-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)" );
|
||||
|
||||
win.name = "test";
|
||||
|
||||
if ( !window.supportsScroll ) {
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
|
||||
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.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
|
||||
// Support: Android 2.3 only
|
||||
// Android 2.3 is sometimes off by a few pixels.
|
||||
window.scrollTo( 0, 0 );
|
||||
if ( /android 2\.3/i.test( navigator.userAgent ) ) {
|
||||
assert.ok(
|
||||
Math.abs( $( window ).scrollTop() ) < 5,
|
||||
"jQuery(window).scrollTop() other window"
|
||||
);
|
||||
} else {
|
||||
assert.equal( $( window ).scrollTop(), 0, "jQuery(window).scrollTop() other window" );
|
||||
}
|
||||
assert.equal( $( window ).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
|
||||
if ( /android 2\.3/i.test( navigator.userAgent ) ) {
|
||||
assert.ok(
|
||||
Math.abs( $( window ).scrollTop() ) < 5,
|
||||
"jQuery(window).scrollTop() other document"
|
||||
);
|
||||
} else {
|
||||
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.strictEqual( $().scrollTop(), undefined, "jQuery().scrollTop() testing getter on empty jquery object" );
|
||||
assert.strictEqual( $().scrollLeft(), undefined, "jQuery().scrollLeft() testing getter 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( 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 );
|
||||
|
||||
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 );
|
||||
var coords = { "top": 1, "left": 1 };
|
||||
assert.equal( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
|
||||
assert.equal( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
|
||||
assert.equal( jQuery("#absolute-1").offset(undefined).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
|
||||
});
|
||||
|
||||
QUnit.test( "offsetParent", function( assert ) {
|
||||
assert.expect( 13 );
|
||||
|
||||
var body, header, div, area;
|
||||
|
||||
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." );
|
||||
|
||||
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." );
|
||||
|
||||
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." );
|
||||
|
||||
jQuery( "#nothiddendiv" ).css( "position", "relative" );
|
||||
|
||||
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." );
|
||||
|
||||
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." );
|
||||
|
||||
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.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "fractions (see #7730 and #7885)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
jQuery( "body" ).append( "<div id='fractions'/>" );
|
||||
|
||||
var result,
|
||||
expected = { "top": 1000, "left": 1000 },
|
||||
div = jQuery( "#fractions" );
|
||||
|
||||
div.css( {
|
||||
"position": "absolute",
|
||||
"left": "1000.7432222px",
|
||||
"top": "1000.532325px",
|
||||
"width": 100,
|
||||
"height": 100
|
||||
} );
|
||||
|
||||
div.offset( expected );
|
||||
|
||||
result = div.offset();
|
||||
|
||||
// Support: Chrome 45-46+
|
||||
// In recent Chrome these values differ a little.
|
||||
assert.ok( Math.abs( result.top - expected.top ) < 0.25, "Check top within 0.25 of expected" );
|
||||
assert.equal( result.left, expected.left, "Check left" );
|
||||
|
||||
div.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "iframe scrollTop/Left (see gh-1945)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var ifDoc = jQuery( "#iframe" )[ 0 ].contentDocument;
|
||||
|
||||
// Mobile Safari and Android 2.3 resize the iframe by its content
|
||||
// meaning it's not possible to scroll the iframe only its parent element.
|
||||
// It seems (not confirmed) in android 4.0 it's not possible to scroll iframes from the code.
|
||||
// Opera 12.1x also has problems with this test.
|
||||
if ( /iphone os/i.test( navigator.userAgent ) ||
|
||||
/android 2\.3/i.test( navigator.userAgent ) ||
|
||||
/android 4\.0/i.test( navigator.userAgent ) ||
|
||||
/opera.*version\/12\.1/i.test( navigator.userAgent ) ) {
|
||||
assert.equal( true, true, "Can't scroll iframes in this environment" );
|
||||
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>" );
|
||||
|
||||
jQuery( ifDoc ).scrollTop( 200 );
|
||||
jQuery( ifDoc ).scrollLeft( 500 );
|
||||
|
||||
assert.equal( jQuery( ifDoc ).scrollTop(), 200, "$($('#iframe')[0].contentDocument).scrollTop()" );
|
||||
assert.equal( jQuery( ifDoc ).scrollLeft(), 500, "$($('#iframe')[0].contentDocument).scrollLeft()" );
|
||||
}
|
||||
} );
|
||||
|
||||
} )();
|
324
dashboard-ui/bower_components/jquery/test/unit/queue.js
vendored
Normal file
324
dashboard-ui/bower_components/jquery/test/unit/queue.js
vendored
Normal file
|
@ -0,0 +1,324 @@
|
|||
QUnit.module( "queue", { teardown: moduleTeardown } );
|
||||
|
||||
QUnit.test( "queue() with other types", function( assert ) {
|
||||
assert.expect( 14 );
|
||||
|
||||
QUnit.stop();
|
||||
|
||||
var $div = jQuery( {} ),
|
||||
counter = 0;
|
||||
|
||||
$div.promise( "foo" ).done( function() {
|
||||
assert.equal( counter, 0, "Deferred for collection with no queue is automatically resolved" );
|
||||
} );
|
||||
|
||||
$div
|
||||
.queue( "foo", function() {
|
||||
assert.equal( ++counter, 1, "Dequeuing" );
|
||||
jQuery.dequeue( this, "foo" );
|
||||
} )
|
||||
.queue( "foo", function() {
|
||||
assert.equal( ++counter, 2, "Dequeuing" );
|
||||
jQuery( this ).dequeue( "foo" );
|
||||
} )
|
||||
.queue( "foo", function() {
|
||||
assert.equal( ++counter, 3, "Dequeuing" );
|
||||
} )
|
||||
.queue( "foo", function() {
|
||||
assert.equal( ++counter, 4, "Dequeuing" );
|
||||
} );
|
||||
|
||||
$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", undefined ).queue( "foo" ).length, 4, ".queue('name',undefined) does nothing but is chainable (#5571)" );
|
||||
|
||||
$div.dequeue( "foo" );
|
||||
|
||||
assert.equal( counter, 3, "Testing previous call to dequeue" );
|
||||
assert.equal( $div.queue( "foo" ).length, 1, "Testing queue length" );
|
||||
|
||||
$div.dequeue( "foo" );
|
||||
|
||||
assert.equal( counter, 4, "Testing previous call to dequeue" );
|
||||
assert.equal( $div.queue( "foo" ).length, 0, "Testing queue length" );
|
||||
|
||||
$div.dequeue( "foo" );
|
||||
|
||||
assert.equal( counter, 4, "Testing previous call to dequeue" );
|
||||
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 );
|
||||
|
||||
var div = jQuery( {} ),
|
||||
counter = 0;
|
||||
|
||||
div.queue( "foo", function( next ) {
|
||||
assert.equal( ++counter, 1, "Dequeueing" );
|
||||
next();
|
||||
} ).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()" );
|
||||
} );
|
||||
|
||||
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.stop();
|
||||
|
||||
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" );
|
||||
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" );
|
||||
QUnit.start();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "callbacks keep their place in the queue", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
QUnit.stop();
|
||||
var div = jQuery( "<div>" ),
|
||||
counter = 0;
|
||||
|
||||
div.queue( function( next ) {
|
||||
assert.equal( ++counter, 1, "Queue/callback order: first called" );
|
||||
setTimeout( next, 200 );
|
||||
} ).delay( 100 ).queue( function( next ) {
|
||||
assert.equal( ++counter, 2, "Queue/callback order: second called" );
|
||||
jQuery( this ).delay( 100 ).queue( function( next ) {
|
||||
assert.equal( ++counter, 4, "Queue/callback order: fourth called" );
|
||||
next();
|
||||
} );
|
||||
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" );
|
||||
QUnit.start();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.queue should return array while manipulating the queue", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
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.stop();
|
||||
|
||||
var foo = jQuery( {} ), run = 0;
|
||||
|
||||
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.stop();
|
||||
|
||||
var div = jQuery( {} ),
|
||||
counter = 0;
|
||||
|
||||
div.queue( "foo", function( next ) {
|
||||
counter++;
|
||||
jQuery( this ).clearQueue( "foo" );
|
||||
next();
|
||||
} ).queue( "foo", function() {
|
||||
counter++;
|
||||
} );
|
||||
|
||||
div.promise( "foo" ).done( function() {
|
||||
assert.ok( true, "dequeue resolves the deferred" );
|
||||
QUnit.start();
|
||||
} );
|
||||
|
||||
div.dequeue( "foo" );
|
||||
|
||||
assert.equal( counter, 1, "the queue was cleared" );
|
||||
} );
|
||||
|
||||
QUnit.test( "clearQueue() clears the fx queue", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var div = jQuery( {} ),
|
||||
counter = 0;
|
||||
|
||||
div.queue( function( next ) {
|
||||
counter++;
|
||||
var self = this;
|
||||
setTimeout( function() { jQuery( self ).clearQueue(); next(); }, 50 );
|
||||
} ).queue( function() {
|
||||
counter++;
|
||||
} );
|
||||
|
||||
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 ) {
|
||||
assert.strictEqual( test++, 2, "step two" );
|
||||
setTimeout( function() {
|
||||
next();
|
||||
assert.strictEqual( test++, 4, "step four" );
|
||||
QUnit.start();
|
||||
}, 10 );
|
||||
} ).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( {
|
||||
top: 100
|
||||
}, {
|
||||
duration: 1,
|
||||
queue: "queue",
|
||||
complete: function() {
|
||||
assert.strictEqual( test++, 1, "step one" );
|
||||
}
|
||||
} ).dequeue( "queue" );
|
||||
|
||||
foo.promise( "queue" ).done( function() {
|
||||
assert.strictEqual( test++, 2, "step two" );
|
||||
QUnit.start();
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
QUnit.test( ".promise(obj)", function( assert ) {
|
||||
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 ) {
|
||||
assert.expect( 3 );
|
||||
QUnit.stop();
|
||||
|
||||
var done = {};
|
||||
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
|
||||
.stop( "alternate", false, false )
|
||||
|
||||
// this test
|
||||
.delay( 1 )
|
||||
.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() {
|
||||
QUnit.start();
|
||||
}, 1500 );
|
||||
} );
|
||||
|
||||
QUnit.asyncTest( "queue stop hooks", 2, function( assert ) {
|
||||
var foo = jQuery( "#foo" );
|
||||
|
||||
foo.queue( function( next, hooks ) {
|
||||
hooks.stop = function( gotoEnd ) {
|
||||
assert.equal( !!gotoEnd, false, "Stopped without gotoEnd" );
|
||||
};
|
||||
} );
|
||||
foo.stop();
|
||||
|
||||
foo.queue( function( next, hooks ) {
|
||||
hooks.stop = function( gotoEnd ) {
|
||||
assert.equal( gotoEnd, true, "Stopped with gotoEnd" );
|
||||
QUnit.start();
|
||||
};
|
||||
} );
|
||||
|
||||
foo.stop( false, true );
|
||||
} );
|
||||
|
||||
} // if ( jQuery.fn.stop )
|
83
dashboard-ui/bower_components/jquery/test/unit/ready.js
vendored
Normal file
83
dashboard-ui/bower_components/jquery/test/unit/ready.js
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
QUnit.module( "ready" );
|
||||
|
||||
( function() {
|
||||
var notYetReady, noEarlyExecution,
|
||||
order = [],
|
||||
args = {};
|
||||
|
||||
notYetReady = !jQuery.isReady;
|
||||
|
||||
QUnit.test( "jQuery.isReady", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
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 ) {
|
||||
|
||||
// When returned function is executed, push testId onto `order` array
|
||||
// to ensure execution order. Also, store event handler arg to ensure
|
||||
// the correct arg is being passed into the event handler.
|
||||
return function( arg ) {
|
||||
order.push( testId );
|
||||
args[ testId ] = arg;
|
||||
};
|
||||
}
|
||||
|
||||
// Bind to the ready event in every possible way.
|
||||
jQuery( makeHandler( "a" ) );
|
||||
jQuery( document ).ready( makeHandler( "b" ) );
|
||||
jQuery( document ).on( "ready.readytest", makeHandler( "c" ) );
|
||||
|
||||
// Do it twice, just to be sure.
|
||||
jQuery( makeHandler( "d" ) );
|
||||
jQuery( document ).ready( makeHandler( "e" ) );
|
||||
jQuery( document ).on( "ready.readytest", makeHandler( "f" ) );
|
||||
|
||||
noEarlyExecution = order.length === 0;
|
||||
|
||||
// This assumes that QUnit tests are run on DOM ready!
|
||||
QUnit.test( "jQuery ready", function( assert ) {
|
||||
assert.expect( 10 );
|
||||
|
||||
assert.ok( noEarlyExecution, "Handlers bound to DOM ready should not execute before DOM ready" );
|
||||
|
||||
// Ensure execution order.
|
||||
assert.deepEqual( order, [ "a", "b", "d", "e", "c", "f" ],
|
||||
"Bound DOM ready handlers should execute in on-order, but those bound with" +
|
||||
"jQuery(document).on( 'ready', fn ) will always execute last" );
|
||||
|
||||
// Ensure handler argument is correct.
|
||||
assert.equal( args[ "a" ], jQuery,
|
||||
"Argument passed to fn in jQuery( fn ) should be jQuery" );
|
||||
assert.equal( args[ "b" ], jQuery,
|
||||
"Argument passed to fn in jQuery(document).ready( fn ) should be jQuery" );
|
||||
assert.ok( args[ "c" ] instanceof jQuery.Event,
|
||||
"Argument passed to fn in jQuery(document).on( 'ready', fn )" +
|
||||
" should be an event object" );
|
||||
|
||||
order = [];
|
||||
|
||||
// Now that the ready event has fired, again bind to the ready event
|
||||
// in every possible way. These event handlers should execute immediately.
|
||||
jQuery( makeHandler( "g" ) );
|
||||
assert.equal( order.pop(), "g", "Event handler should execute immediately" );
|
||||
assert.equal( args[ "g" ], jQuery,
|
||||
"Argument passed to fn in jQuery( fn ) should be jQuery" );
|
||||
|
||||
jQuery( document ).ready( makeHandler( "h" ) );
|
||||
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" );
|
||||
|
||||
jQuery( document ).on( "ready.readytest", makeHandler( "never" ) );
|
||||
assert.equal( order.length, 0,
|
||||
"Event handler should never execute since DOM ready has already passed" );
|
||||
|
||||
// Cleanup.
|
||||
jQuery( document ).off( "ready.readytest" );
|
||||
} );
|
||||
|
||||
} )();
|
536
dashboard-ui/bower_components/jquery/test/unit/selector.js
vendored
Normal file
536
dashboard-ui/bower_components/jquery/test/unit/selector.js
vendored
Normal file
|
@ -0,0 +1,536 @@
|
|||
QUnit.module( "selector", { teardown: moduleTeardown } );
|
||||
|
||||
/**
|
||||
* This test page is for selector tests that require jQuery in order to do the selection
|
||||
*/
|
||||
|
||||
QUnit.test( "element", function( assert ) {
|
||||
assert.expect( 7 );
|
||||
|
||||
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.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" );
|
||||
} );
|
||||
|
||||
QUnit.test( "id", function( assert ) {
|
||||
assert.expect( 26 );
|
||||
|
||||
var a;
|
||||
|
||||
assert.t( "ID Selector", "#body", [ "body" ] );
|
||||
assert.t( "ID Selector w/ Element", "body#body", [ "body" ] );
|
||||
assert.t( "ID Selector w/ Element", "ul#first", [] );
|
||||
assert.t( "ID selector with existing ID descendant", "#firstp #simon1", [ "simon1" ] );
|
||||
assert.t( "ID selector with non-existent descendant", "#firstp #foobar", [] );
|
||||
assert.t( "ID selector using UTF8", "#台北Táiběi", [ "台北Táiběi" ] );
|
||||
assert.t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", [ "台北Táiběi", "台北" ] );
|
||||
assert.t( "Descendant ID selector using UTF8", "div #台北", [ "台北" ] );
|
||||
assert.t( "Child ID selector using UTF8", "form > #台北", [ "台北" ] );
|
||||
|
||||
assert.t( "Escaped ID", "#foo\\:bar", [ "foo:bar" ] );
|
||||
assert.t( "Escaped ID", "#test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
|
||||
assert.t( "Descendant escaped ID", "div #foo\\:bar", [ "foo:bar" ] );
|
||||
assert.t( "Descendant escaped ID", "div #test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
|
||||
assert.t( "Child escaped ID", "form > #foo\\:bar", [ "foo:bar" ] );
|
||||
assert.t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
|
||||
|
||||
assert.t( "ID Selector, child ID present", "#form > #radio1", [ "radio1" ] ); // bug #267
|
||||
assert.t( "ID Selector, not an ancestor ID", "#form #first", [] );
|
||||
assert.t( "ID Selector, not a child ID", "#form > #option1a", [] );
|
||||
|
||||
assert.t( "All Children of ID", "#foo > *", [ "sndp", "en", "sap" ] );
|
||||
assert.t( "All Children of ID with no children", "#firstUL > *", [] );
|
||||
|
||||
a = jQuery( "<a id='backslash\\foo'></a>" ).appendTo( "#qunit-fixture" );
|
||||
assert.t( "ID Selector contains backslash", "#backslash\\\\foo", [ "backslash\\foo" ] );
|
||||
|
||||
assert.t( "ID Selector on Form with an input that has a name of 'id'", "#lengthtest", [ "lengthtest" ] );
|
||||
|
||||
assert.t( "ID selector with non-existent ancestor", "#asdfasdf #foobar", [] ); // bug #986
|
||||
|
||||
assert.t( "Underscore ID", "#types_all", [ "types_all" ] );
|
||||
assert.t( "Dash ID", "#qunit-fixture", [ "qunit-fixture" ] );
|
||||
|
||||
assert.t( "ID with weird characters in it", "#name\\+value", [ "name+value" ] );
|
||||
} );
|
||||
|
||||
QUnit.test( "class", 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." );
|
||||
} );
|
||||
|
||||
QUnit.test( "name", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var form;
|
||||
|
||||
assert.t( "Name selector", "input[name=action]", [ "text1" ] );
|
||||
assert.t( "Name selector with single quotes", "input[name='action']", [ "text1" ] );
|
||||
assert.t( "Name selector with double quotes", "input[name=\"action\"]", [ "text1" ] );
|
||||
|
||||
assert.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.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "selectors with comma", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var fixture = jQuery( "<div><h2><span/></h2><div><p><span/></p><p/></div></div>" );
|
||||
|
||||
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>" );
|
||||
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 );
|
||||
|
||||
assert.t( "Child", "p > a", [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] );
|
||||
assert.t( "Child", "p> a", [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] );
|
||||
assert.t( "Child", "p >a", [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] );
|
||||
assert.t( "Child", "p>a", [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] );
|
||||
assert.t( "Child w/ Class", "p > a.blog", [ "mark", "simon" ] );
|
||||
assert.t( "All Children", "code > *", [ "anchor1", "anchor2" ] );
|
||||
assert.t( "All Grandchildren", "p > * > *", [ "anchor1", "anchor2" ] );
|
||||
assert.t( "Adjacent", "p + p", [ "ap", "en", "sap" ] );
|
||||
assert.t( "Adjacent", "p#firstp + p", [ "ap" ] );
|
||||
assert.t( "Adjacent", "p[lang=en] + p", [ "sap" ] );
|
||||
assert.t( "Adjacent", "a.GROUPS + code + a", [ "mark" ] );
|
||||
assert.t( "Element Preceded By", "#groups ~ a", [ "mark" ] );
|
||||
assert.t( "Element Preceded By", "#length ~ input", [ "idTest" ] );
|
||||
assert.t( "Element Preceded By", "#siblingfirst ~ em", [ "siblingnext", "siblingthird" ] );
|
||||
assert.t( "Element Preceded By (multiple)", "#siblingTest em ~ em ~ em ~ span", [ "siblingspan" ] );
|
||||
|
||||
if ( jQuery.find.compile ) {
|
||||
assert.t( "Element Preceded By, Containing", "#liveHandlerOrder ~ div em:contains('1')", [ "siblingfirst" ] );
|
||||
assert.t( "Combinators are not skipped when mixing general and specific", "#siblingTest > em:contains('x') + em ~ span", [] );
|
||||
assert.equal( jQuery( "#listWithTabIndex li:eq(2) ~ li" ).length, 1, "Find by general sibling combinator (#8310)" );
|
||||
} else {
|
||||
assert.ok( "skip", ":contains not supported in selector-native" );
|
||||
assert.ok( "skip", ":contains not supported in selector-native" );
|
||||
assert.ok( "skip", ":eq not supported in selector-native" );
|
||||
}
|
||||
|
||||
assert.t( "Multiple combinators selects all levels", "#siblingTest em *", [ "siblingchild", "siblinggrandchild", "siblinggreatgrandchild" ] );
|
||||
assert.t( "Multiple combinators selects all levels", "#siblingTest > em *", [ "siblingchild", "siblinggrandchild", "siblinggreatgrandchild" ] );
|
||||
assert.t( "Multiple sibling combinators doesn't miss general siblings", "#siblingTest > em:first-child + em ~ span", [ "siblingspan" ] );
|
||||
|
||||
assert.equal( jQuery( "#listWithTabIndex" ).length, 1, "Parent div for next test is found via ID (#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.t( "Verify deep class selector", "div.blah > p > a", [] );
|
||||
assert.t( "No element deep selector", "div.foo > span > a", [] );
|
||||
assert.t( "Non-existent ancestors", ".fototab > .thumbnails > a", [] );
|
||||
} );
|
||||
|
||||
QUnit.test( "attributes", function( assert ) {
|
||||
assert.expect( 54 );
|
||||
|
||||
var attrbad, div, withScript;
|
||||
|
||||
assert.t( "Find elements with a tabindex attribute", "[tabindex]", [ "listWithTabIndex", "foodWithNegativeTabIndex", "linkWithTabIndex", "linkWithNegativeTabIndex", "linkWithNoHrefWithTabIndex", "linkWithNoHrefWithNegativeTabIndex" ] );
|
||||
|
||||
assert.t( "Attribute Exists", "#qunit-fixture a[title]", [ "google" ] );
|
||||
assert.t( "Attribute Exists (case-insensitive)", "#qunit-fixture a[TITLE]", [ "google" ] );
|
||||
assert.t( "Attribute Exists", "#qunit-fixture *[title]", [ "google" ] );
|
||||
assert.t( "Attribute Exists", "#qunit-fixture [title]", [ "google" ] );
|
||||
assert.t( "Attribute Exists", "#qunit-fixture a[ title ]", [ "google" ] );
|
||||
|
||||
assert.t( "Boolean attribute exists", "#select2 option[selected]", [ "option2d" ] );
|
||||
assert.t( "Boolean attribute equals", "#select2 option[selected='selected']", [ "option2d" ] );
|
||||
|
||||
assert.t( "Attribute Equals", "#qunit-fixture a[rel='bookmark']", [ "simon1" ] );
|
||||
assert.t( "Attribute Equals", "#qunit-fixture a[rel='bookmark']", [ "simon1" ] );
|
||||
assert.t( "Attribute Equals", "#qunit-fixture a[rel=bookmark]", [ "simon1" ] );
|
||||
assert.t( "Attribute Equals", "#qunit-fixture a[href='http://www.google.com/']", [ "google" ] );
|
||||
assert.t( "Attribute Equals", "#qunit-fixture a[ rel = 'bookmark' ]", [ "simon1" ] );
|
||||
assert.t( "Attribute Equals Number", "#qunit-fixture option[value='1']", [ "option1b", "option2b", "option3b", "option4b", "option5c" ] );
|
||||
assert.t( "Attribute Equals Number", "#qunit-fixture li[tabIndex='-1']", [ "foodWithNegativeTabIndex" ] );
|
||||
|
||||
document.getElementById( "anchor2" ).href = "#2";
|
||||
assert.t( "href Attribute", "p a[href^='#']", [ "anchor2" ] );
|
||||
assert.t( "href Attribute", "p a[href*='#']", [ "simon1", "anchor2" ] );
|
||||
|
||||
assert.t( "for Attribute", "form label[for]", [ "label-for" ] );
|
||||
assert.t( "for Attribute in form", "#form [for=action]", [ "label-for" ] );
|
||||
|
||||
assert.t( "Attribute containing []", "input[name^='foo[']", [ "hidden2" ] );
|
||||
assert.t( "Attribute containing []", "input[name^='foo[bar]']", [ "hidden2" ] );
|
||||
assert.t( "Attribute containing []", "input[name*='[bar]']", [ "hidden2" ] );
|
||||
assert.t( "Attribute containing []", "input[name$='bar]']", [ "hidden2" ] );
|
||||
assert.t( "Attribute containing []", "input[name$='[bar]']", [ "hidden2" ] );
|
||||
assert.t( "Attribute containing []", "input[name$='foo[bar]']", [ "hidden2" ] );
|
||||
assert.t( "Attribute containing []", "input[name*='foo[bar]']", [ "hidden2" ] );
|
||||
|
||||
assert.t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type='hidden']", [ "radio1", "radio2", "hidden1" ] );
|
||||
assert.t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type=\"hidden\"]", [ "radio1", "radio2", "hidden1" ] );
|
||||
assert.t( "Multiple Attribute Equals", "#form input[type='radio'], #form input[type=hidden]", [ "radio1", "radio2", "hidden1" ] );
|
||||
|
||||
assert.t( "Attribute selector using UTF8", "span[lang=中文]", [ "台北" ] );
|
||||
|
||||
assert.t( "Attribute Begins With", "a[href ^= 'http://www']", [ "google", "yahoo" ] );
|
||||
assert.t( "Attribute Ends With", "a[href $= 'org/']", [ "mark" ] );
|
||||
assert.t( "Attribute Contains", "a[href *= 'google']", [ "google", "groups" ] );
|
||||
|
||||
if ( jQuery.find.compile ) {
|
||||
assert.t( "Empty values", "#select1 option[value!='']", [ "option1b", "option1c", "option1d" ] );
|
||||
assert.t( "Attribute Is Not Equal", "#ap a[hreflang!='en']", [ "google", "groups", "anchor1" ] );
|
||||
assert.t( "Select options via :selected", "#select1 option:selected", [ "option1a" ] );
|
||||
assert.t( "Select options via :selected", "#select2 option:selected", [ "option2d" ] );
|
||||
assert.t( "Select options via :selected", "#select3 option:selected", [ "option3b", "option3c" ] );
|
||||
assert.t( "Select options via :selected", "select[name='select2'] option:selected", [ "option2d" ] );
|
||||
} else {
|
||||
assert.ok( "skip", "!= not supported in selector-native" );
|
||||
assert.ok( "skip", "!= not supported in selector-native" );
|
||||
assert.ok( "skip", ":selected not supported in selector-native" );
|
||||
assert.ok( "skip", ":selected not supported in selector-native" );
|
||||
assert.ok( "skip", ":selected not supported in selector-native" );
|
||||
assert.ok( "skip", ":selected not supported in selector-native" );
|
||||
}
|
||||
|
||||
assert.t( "Empty values", "#select1 option[value='']", [ "option1a" ] );
|
||||
|
||||
assert.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
|
||||
attrbad = jQuery(
|
||||
"<input type='hidden' id='attrbad_space' name='foo bar'/>" +
|
||||
"<input type='hidden' id='attrbad_dot' value='2' name='foo.baz'/>" +
|
||||
"<input type='hidden' id='attrbad_brackets' value='2' name='foo[baz]'/>" +
|
||||
"<input type='hidden' id='attrbad_injection' data-attr='foo_baz']'/>" +
|
||||
"<input type='hidden' id='attrbad_quote' data-attr='''/>" +
|
||||
"<input type='hidden' id='attrbad_backslash' data-attr='\'/>" +
|
||||
"<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();
|
||||
|
||||
assert.t( "Underscores don't need escaping", "input[id=types_all]", [ "types_all" ] );
|
||||
|
||||
assert.t( "input[type=text]", "#form input[type=text]", [ "text1", "text2", "hidden2", "name" ] );
|
||||
assert.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" );
|
||||
assert.t( "Object.prototype property \"constructor\" (negative)", "[constructor]", [] );
|
||||
assert.t( "Gecko Object.prototype property \"watch\" (negative)", "[watch]", [] );
|
||||
div.setAttribute( "constructor", "foo" );
|
||||
div.setAttribute( "watch", "bar" );
|
||||
assert.t( "Object.prototype property \"constructor\"", "[constructor='foo']", [ "foo" ] );
|
||||
assert.t( "Gecko Object.prototype property \"watch\"", "[watch='bar']", [ "foo" ] );
|
||||
|
||||
assert.t( "Value attribute is retrieved correctly", "input[value=Test]", [ "text1", "text2" ] );
|
||||
|
||||
if ( jQuery.find.compile ) {
|
||||
|
||||
// #12600
|
||||
assert.ok(
|
||||
jQuery( "<select value='12600'><option value='option' selected='selected'></option><option value=''></option></select>" )
|
||||
.prop( "value", "option" )
|
||||
.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']" ),
|
||||
":input[value=foo] selects text input by attribute"
|
||||
);
|
||||
} else {
|
||||
assert.ok( "skip", ":input not supported in selector-native" );
|
||||
assert.ok( "skip", ":input not supported in selector-native" );
|
||||
}
|
||||
|
||||
// #11115
|
||||
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]" ),
|
||||
"[checked] selects by attribute (negative)"
|
||||
);
|
||||
} );
|
||||
|
||||
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." );
|
||||
} );
|
||||
|
||||
QUnit[ jQuery.find.compile ? "test" : "skip" ]( "disconnected nodes", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
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" );
|
||||
} );
|
||||
|
||||
testIframe(
|
||||
"selector/html5_selector",
|
||||
"attributes - jQuery.attr",
|
||||
function( jQuery, window, document, assert ) {
|
||||
assert.expect( 38 );
|
||||
|
||||
/**
|
||||
* Returns an array of elements with the given IDs
|
||||
* q & t are added here for the iFrame's context
|
||||
*/
|
||||
function q() {
|
||||
var r = [],
|
||||
i = 0;
|
||||
|
||||
for ( ; i < arguments.length; i++ ) {
|
||||
r.push( document.getElementById( arguments[ i ] ) );
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a select matches the given IDs
|
||||
* @example t("Check for something", "//[a]", ["foo", "bar"]);
|
||||
* @param {String} a - Assertion name
|
||||
* @param {String} b - Sizzle selector
|
||||
* @param {Array} c - Array of ids to construct what is expected
|
||||
*/
|
||||
function t( a, b, c ) {
|
||||
var f = jQuery( b ).get(),
|
||||
s = "",
|
||||
i = 0;
|
||||
|
||||
for ( ; i < f.length; i++ ) {
|
||||
s += ( s && "," ) + "'" + f[ i ].id + "'";
|
||||
}
|
||||
|
||||
assert.deepEqual( f, q.apply( q, c ), a + " (" + b + ")" );
|
||||
}
|
||||
|
||||
// ====== All known boolean attributes, including html5 booleans ======
|
||||
// autobuffer, autofocus, autoplay, async, checked,
|
||||
// compact, controls, declare, defer, disabled,
|
||||
// formnovalidate, hidden, indeterminate (property only),
|
||||
// ismap, itemscope, loop, multiple, muted, nohref, noresize,
|
||||
// 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" ] );
|
||||
|
||||
// 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" ] );
|
||||
|
||||
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" ] );
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test( "jQuery.contains", function( assert ) {
|
||||
assert.expect( 16 );
|
||||
|
||||
var container = document.getElementById( "nonnodes" ),
|
||||
element = container.firstChild,
|
||||
text = element.nextSibling,
|
||||
nonContained = container.nextSibling,
|
||||
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)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.uniqueSort", function( assert ) {
|
||||
assert.expect( 15 );
|
||||
|
||||
function Arrayish( arr ) {
|
||||
var i = this.length = arr.length;
|
||||
while ( i-- ) {
|
||||
this[ i ] = arr[ i ];
|
||||
}
|
||||
}
|
||||
Arrayish.prototype = {
|
||||
slice: [].slice,
|
||||
sort: [].sort,
|
||||
splice: [].splice
|
||||
};
|
||||
|
||||
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" ) );
|
||||
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
detached.push( document.createElement( "li" ) );
|
||||
detached[ i ].id = "detached" + i;
|
||||
detached2.appendChild( document.createElement( "li" ) ).id = "detachedChild" + i;
|
||||
}
|
||||
|
||||
tests = {
|
||||
"Empty": {
|
||||
input: [],
|
||||
expected: []
|
||||
},
|
||||
"Single-element": {
|
||||
input: [ fixture ],
|
||||
expected: [ fixture ]
|
||||
},
|
||||
"No duplicates": {
|
||||
input: [ fixture, body ],
|
||||
expected: [ body, fixture ]
|
||||
},
|
||||
"Duplicates": {
|
||||
input: [ body, fixture, fixture, body ],
|
||||
expected: [ body, fixture ]
|
||||
},
|
||||
"Detached": {
|
||||
input: detached.slice( 0 ),
|
||||
expected: detached.slice( 0 )
|
||||
},
|
||||
"Detached children": {
|
||||
input: [
|
||||
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 ]
|
||||
]
|
||||
},
|
||||
"Attached/detached mixture": {
|
||||
input: [ detached1, fixture, detached2, document, detachedChild, body, detachedGrandchild ],
|
||||
expected: [ document, body, fixture ],
|
||||
length: 3
|
||||
}
|
||||
};
|
||||
|
||||
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.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" ];
|
||||
|
||||
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" );
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.asyncTest( "Iframe dispatch should not affect jQuery (#13936)", 1, function( assert ) {
|
||||
var loaded = false,
|
||||
thrown = false,
|
||||
iframe = document.getElementById( "iframe" ),
|
||||
iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
|
||||
|
||||
jQuery( iframe ).on( "load", function() {
|
||||
var form;
|
||||
|
||||
try {
|
||||
iframeDoc = this.contentDocument || this.contentWindow.document;
|
||||
form = jQuery( "#navigate", iframeDoc )[ 0 ];
|
||||
} catch ( e ) {
|
||||
thrown = e;
|
||||
}
|
||||
|
||||
if ( loaded ) {
|
||||
assert.strictEqual( thrown, false, "No error thrown from post-reload jQuery call" );
|
||||
|
||||
// clean up
|
||||
jQuery( iframe ).off();
|
||||
|
||||
QUnit.start();
|
||||
} else {
|
||||
loaded = true;
|
||||
form.submit();
|
||||
}
|
||||
} );
|
||||
|
||||
iframeDoc.open();
|
||||
iframeDoc.write( "<body><form id='navigate' action='?'></form></body>" );
|
||||
iframeDoc.close();
|
||||
} );
|
150
dashboard-ui/bower_components/jquery/test/unit/serialize.js
vendored
Normal file
150
dashboard-ui/bower_components/jquery/test/unit/serialize.js
vendored
Normal file
|
@ -0,0 +1,150 @@
|
|||
QUnit.module( "serialize", { teardown: moduleTeardown } );
|
||||
|
||||
QUnit.test( "jQuery.param()", function( assert ) {
|
||||
assert.expect( 23 );
|
||||
|
||||
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 = { "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 = { "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": { "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": [ 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" );
|
||||
|
||||
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." );
|
||||
|
||||
// #7945
|
||||
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 };
|
||||
|
||||
if ( jQuery.ajaxSettings ) {
|
||||
jQuery.ajaxSetup( settings );
|
||||
} else {
|
||||
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 = { "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[]":[ "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 = { 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)" );
|
||||
|
||||
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." );
|
||||
|
||||
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" );
|
||||
|
||||
params = { "test": [ 1, 2, null ] };
|
||||
assert.equal( jQuery.param( params, false ), "test%5B%5D=1&test%5B%5D=2&test%5B%5D=", "object with array property with null value" );
|
||||
|
||||
if ( jQuery.ajaxSettings === settings ) {
|
||||
delete jQuery.ajaxSettings;
|
||||
} else {
|
||||
jQuery.ajaxSetup( { traditional: false } );
|
||||
}
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.param() Constructed prop values", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
/** @constructor */
|
||||
function Record() {
|
||||
this[ "prop" ] = "val";
|
||||
}
|
||||
|
||||
var MyString = String,
|
||||
MyNumber = Number,
|
||||
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 ) };
|
||||
assert.equal( jQuery.param( params, false ), "test=5", "Do not mistake new Number() for a plain object" );
|
||||
|
||||
params = { "test": new Date() };
|
||||
assert.ok( jQuery.param( params, false ), "(Non empty string returned) Do not mistake new Date() for a plain object" );
|
||||
|
||||
// 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" );
|
||||
} );
|
||||
|
||||
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(
|
||||
"<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(),
|
||||
"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" );
|
||||
|
||||
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" );
|
||||
|
||||
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" );
|
||||
|
||||
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" );
|
||||
|
||||
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" );
|
||||
|
||||
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();
|
||||
} );
|
375
dashboard-ui/bower_components/jquery/test/unit/support.js
vendored
Normal file
375
dashboard-ui/bower_components/jquery/test/unit/support.js
vendored
Normal file
|
@ -0,0 +1,375 @@
|
|||
QUnit.module( "support", { teardown: moduleTeardown } );
|
||||
|
||||
var computedSupport = getComputedSupport( jQuery.support );
|
||||
|
||||
function getComputedSupport( support ) {
|
||||
var prop,
|
||||
result = {};
|
||||
|
||||
for ( prop in support ) {
|
||||
if ( typeof support[ prop ] === "function" ) {
|
||||
result[ prop ] = support[ prop ]();
|
||||
} else {
|
||||
result[ prop ] = support[ prop ];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if ( jQuery.css ) {
|
||||
testIframeWithCallback(
|
||||
"body background is not lost if set prior to loading jQuery (#9239)",
|
||||
"support/bodyBackground.html",
|
||||
function( color, support, assert ) {
|
||||
assert.expect( 2 );
|
||||
var okValue = {
|
||||
"#000000": true,
|
||||
"rgb(0, 0, 0)": true
|
||||
};
|
||||
assert.ok( okValue[ color ], "color was not reset (" + color + ")" );
|
||||
|
||||
assert.deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// This test checks CSP only for browsers with "Content-Security-Policy" header support
|
||||
// i.e. no old WebKit or old Firefox
|
||||
testIframeWithCallback(
|
||||
"Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions",
|
||||
"support/csp.php",
|
||||
function( support, assert ) {
|
||||
var done = assert.async();
|
||||
|
||||
assert.expect( 2 );
|
||||
assert.deepEqual( jQuery.extend( {}, support ), computedSupport, "No violations of CSP polices" );
|
||||
|
||||
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( done );
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
( function() {
|
||||
var expected,
|
||||
userAgent = window.navigator.userAgent;
|
||||
|
||||
if ( /edge\//i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": false,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": true,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": true,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /opera.*version\/12\.1/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": true,
|
||||
"radioValue": false,
|
||||
"reliableMarginLeft": false,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /(msie 10\.0|trident\/7\.0)/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": false,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": false,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": true,
|
||||
"noCloneChecked": false,
|
||||
"optDisabled": true,
|
||||
"optSelected": false,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": true,
|
||||
"radioValue": false,
|
||||
"reliableMarginLeft": true,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /msie 9\.0/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": false,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": false,
|
||||
"cors": false,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": true,
|
||||
"noCloneChecked": false,
|
||||
"optDisabled": true,
|
||||
"optSelected": false,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": true,
|
||||
"radioValue": false,
|
||||
"reliableMarginLeft": true,
|
||||
"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 = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": true,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": true,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /9\.0(\.\d+|) safari/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": false,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": true,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /8\.0(\.\d+|) safari/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": false,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": false,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": true,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /(?:6|7)\.0(\.\d+|) safari/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": false,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": true,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /5\.1(\.\d+|) safari/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": false,
|
||||
"checkOn": false,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": false,
|
||||
"pixelPosition": false,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": false,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /firefox/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": true,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": false,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /iphone os 9_/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": false,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": true,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /iphone os 8_/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": false,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": false,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": true,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /iphone os (?:6|7)_/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": true,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": false,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": true,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /android 4\.[0-3]/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": false,
|
||||
"checkOn": false,
|
||||
"clearCloneStyle": true,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": true,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": false,
|
||||
"pixelPosition": false,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": false,
|
||||
"reliableMarginRight": true
|
||||
};
|
||||
} else if ( /android 2\.3/i.test( userAgent ) ) {
|
||||
expected = {
|
||||
"ajax": true,
|
||||
"boxSizingReliable": true,
|
||||
"checkClone": true,
|
||||
"checkOn": false,
|
||||
"clearCloneStyle": false,
|
||||
"cors": true,
|
||||
"createHTMLDocument": true,
|
||||
"focusin": false,
|
||||
"noCloneChecked": true,
|
||||
"optDisabled": false,
|
||||
"optSelected": true,
|
||||
"pixelMarginRight": true,
|
||||
"pixelPosition": false,
|
||||
"radioValue": true,
|
||||
"reliableMarginLeft": true,
|
||||
"reliableMarginRight": false
|
||||
};
|
||||
}
|
||||
|
||||
QUnit.test( "Verify that support tests resolve as expected per browser", function( assert ) {
|
||||
if ( !expected ) {
|
||||
assert.expect( 1 );
|
||||
assert.ok( false, "Known client: " + userAgent );
|
||||
}
|
||||
|
||||
var i, prop,
|
||||
j = 0;
|
||||
|
||||
for ( prop in computedSupport ) {
|
||||
j++;
|
||||
}
|
||||
|
||||
assert.expect( j );
|
||||
|
||||
for ( i in expected ) {
|
||||
if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
|
||||
assert.equal( computedSupport[ i ], expected[ i ],
|
||||
"jQuery.support['" + i + "']: " + computedSupport[ i ] +
|
||||
", expected['" + i + "']: " + expected[ i ] );
|
||||
} else {
|
||||
assert.ok( true, "no ajax; skipping jQuery.support['" + i + "']" );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
} )();
|
885
dashboard-ui/bower_components/jquery/test/unit/traversing.js
vendored
Normal file
885
dashboard-ui/bower_components/jquery/test/unit/traversing.js
vendored
Normal file
|
@ -0,0 +1,885 @@
|
|||
QUnit.module( "traversing", { teardown: moduleTeardown } );
|
||||
|
||||
QUnit.test( "find(String)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
assert.equal( jQuery( "#foo" ).find( ".blogTest" ).text(), "Yahoo", "Basic selector" );
|
||||
} );
|
||||
|
||||
QUnit.test( "find(String) under non-elements", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var j = jQuery( "#nonnodes" ).contents();
|
||||
assert.equal( j.find( "div" ).length, 0, "Check node,textnode,comment to find zero divs" );
|
||||
assert.equal( j.find( "div" ).addBack().length, 3, "Check node,textnode,comment to find zero divs, but preserves pushStack" );
|
||||
} );
|
||||
|
||||
QUnit[ jQuery.find.compile ? "test" : "skip" ]( "find(leading combinator)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
assert.deepEqual( jQuery( "#qunit-fixture" ).find( "> div" ).get(), q( "foo", "nothiddendiv", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group" ), "find child elements" );
|
||||
assert.deepEqual( jQuery( "#qunit-fixture" ).find( "> #foo, > #moretests" ).get(), q( "foo", "moretests" ), "find child elements" );
|
||||
assert.deepEqual( jQuery( "#qunit-fixture" ).find( "> #foo > p" ).get(), q( "sndp", "en", "sap" ), "find child elements" );
|
||||
|
||||
assert.deepEqual( jQuery( "#siblingTest, #siblingfirst" ).find( "+ *" ).get(), q( "siblingnext", "fx-test-group" ), "ensure document order" );
|
||||
} );
|
||||
|
||||
QUnit.test( "find(node|jQuery object)", function( assert ) {
|
||||
assert.expect( 13 );
|
||||
|
||||
var $foo = jQuery( "#foo" ),
|
||||
$blog = jQuery( ".blogTest" ),
|
||||
$first = jQuery( "#first" ),
|
||||
$two = $blog.add( $first ),
|
||||
$twoMore = jQuery( "#ap" ).add( $blog ),
|
||||
$fooTwo = $foo.add( $blog );
|
||||
|
||||
assert.equal( $foo.find( $blog ).text(), "Yahoo", "Find with blog jQuery object" );
|
||||
assert.equal( $foo.find( $blog[ 0 ] ).text(), "Yahoo", "Find with blog node" );
|
||||
assert.equal( $foo.find( $first ).length, 0, "#first is not in #foo" );
|
||||
assert.equal( $foo.find( $first[ 0 ] ).length, 0, "#first not in #foo (node)" );
|
||||
assert.deepEqual( $foo.find( $two ).get(), $blog.get(), "Find returns only nodes within #foo" );
|
||||
assert.deepEqual( $foo.find( $twoMore ).get(), $blog.get(), "...regardless of order" );
|
||||
assert.ok( $fooTwo.find( $blog ).is( ".blogTest" ), "Blog is part of the collection, but also within foo" );
|
||||
assert.ok( $fooTwo.find( $blog[ 0 ] ).is( ".blogTest" ), "Blog is part of the collection, but also within foo(node)" );
|
||||
|
||||
assert.equal( $two.find( $foo ).length, 0, "Foo is not in two elements" );
|
||||
assert.equal( $two.find( $foo[ 0 ] ).length, 0, "Foo is not in two elements(node)" );
|
||||
assert.equal( $two.find( $first ).length, 0, "first is in the collection and not within two" );
|
||||
assert.equal( $two.find( $first ).length, 0, "first is in the collection and not within two(node)" );
|
||||
|
||||
assert.equal( $two.find( $foo[ 0 ] ).addBack().length, 2, "find preserves the pushStack, see #12009" );
|
||||
} );
|
||||
|
||||
QUnit.test( "is(String|undefined)", function( assert ) {
|
||||
assert.expect( 23 );
|
||||
assert.ok( jQuery( "#form" ).is( "form" ), "Check for element: A form must be a form" );
|
||||
assert.ok( !jQuery( "#form" ).is( "div" ), "Check for element: A form is not a div" );
|
||||
assert.ok( jQuery( "#mark" ).is( ".blog" ), "Check for class: Expected class 'blog'" );
|
||||
assert.ok( !jQuery( "#mark" ).is( ".link" ), "Check for class: Did not expect class 'link'" );
|
||||
assert.ok( jQuery( "#simon" ).is( ".blog.link" ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
|
||||
assert.ok( !jQuery( "#simon" ).is( ".blogTest" ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
|
||||
assert.ok( jQuery( "#en" ).is( "[lang=\"en\"]" ), "Check for attribute: Expected attribute lang to be 'en'" );
|
||||
assert.ok( !jQuery( "#en" ).is( "[lang=\"de\"]" ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
|
||||
assert.ok( jQuery( "#text1" ).is( "[type=\"text\"]" ), "Check for attribute: Expected attribute type to be 'text'" );
|
||||
assert.ok( !jQuery( "#text1" ).is( "[type=\"radio\"]" ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
|
||||
assert.ok( jQuery( "#text2" ).is( ":disabled" ), "Check for pseudoclass: Expected to be disabled" );
|
||||
assert.ok( !jQuery( "#text1" ).is( ":disabled" ), "Check for pseudoclass: Expected not disabled" );
|
||||
assert.ok( jQuery( "#radio2" ).is( ":checked" ), "Check for pseudoclass: Expected to be checked" );
|
||||
assert.ok( !jQuery( "#radio1" ).is( ":checked" ), "Check for pseudoclass: Expected not checked" );
|
||||
|
||||
assert.ok( !jQuery( "#foo" ).is( 0 ), "Expected false for an invalid expression - 0" );
|
||||
assert.ok( !jQuery( "#foo" ).is( null ), "Expected false for an invalid expression - null" );
|
||||
assert.ok( !jQuery( "#foo" ).is( "" ), "Expected false for an invalid expression - \"\"" );
|
||||
assert.ok( !jQuery( "#foo" ).is( undefined ), "Expected false for an invalid expression - undefined" );
|
||||
assert.ok( !jQuery( "#foo" ).is( { plain: "object" } ), "Check passing invalid object" );
|
||||
|
||||
// test is() with comma-separated expressions
|
||||
assert.ok( jQuery( "#en" ).is( "[lang=\"en\"],[lang=\"de\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
|
||||
assert.ok( jQuery( "#en" ).is( "[lang=\"de\"],[lang=\"en\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
|
||||
assert.ok( jQuery( "#en" ).is( "[lang=\"en\"] , [lang=\"de\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
|
||||
assert.ok( jQuery( "#en" ).is( "[lang=\"de\"] , [lang=\"en\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
|
||||
} );
|
||||
|
||||
QUnit.test( "is() against non-elements (#10178)", function( assert ) {
|
||||
assert.expect( 14 );
|
||||
|
||||
var label, i, test,
|
||||
collection = jQuery( document ),
|
||||
tests = [ "a", "*" ],
|
||||
nonelements = {
|
||||
text: document.createTextNode( "" ),
|
||||
comment: document.createComment( "" ),
|
||||
document: document,
|
||||
window: window,
|
||||
array: [],
|
||||
"plain object": {},
|
||||
"function": function() {}
|
||||
};
|
||||
|
||||
for ( label in nonelements ) {
|
||||
collection[ 0 ] = nonelements[ label ];
|
||||
for ( i = 0; i < tests.length; i++ ) {
|
||||
test = tests[ i ];
|
||||
assert.ok( !collection.is( test ), label + " does not match \"" + test + "\"" );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
QUnit.test( "is(jQuery)", function( assert ) {
|
||||
assert.expect( 19 );
|
||||
assert.ok( jQuery( "#form" ).is( jQuery( "form" ) ), "Check for element: A form is a form" );
|
||||
assert.ok( !jQuery( "#form" ).is( jQuery( "div" ) ), "Check for element: A form is not a div" );
|
||||
assert.ok( jQuery( "#mark" ).is( jQuery( ".blog" ) ), "Check for class: Expected class 'blog'" );
|
||||
assert.ok( !jQuery( "#mark" ).is( jQuery( ".link" ) ), "Check for class: Did not expect class 'link'" );
|
||||
assert.ok( jQuery( "#simon" ).is( jQuery( ".blog.link" ) ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
|
||||
assert.ok( !jQuery( "#simon" ).is( jQuery( ".blogTest" ) ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
|
||||
assert.ok( jQuery( "#en" ).is( jQuery( "[lang=\"en\"]" ) ), "Check for attribute: Expected attribute lang to be 'en'" );
|
||||
assert.ok( !jQuery( "#en" ).is( jQuery( "[lang=\"de\"]" ) ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
|
||||
assert.ok( jQuery( "#text1" ).is( jQuery( "[type=\"text\"]" ) ), "Check for attribute: Expected attribute type to be 'text'" );
|
||||
assert.ok( !jQuery( "#text1" ).is( jQuery( "[type=\"radio\"]" ) ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
|
||||
assert.ok( !jQuery( "#text1" ).is( jQuery( "input:disabled" ) ), "Check for pseudoclass: Expected not disabled" );
|
||||
assert.ok( jQuery( "#radio2" ).is( jQuery( "input:checked" ) ), "Check for pseudoclass: Expected to be checked" );
|
||||
assert.ok( !jQuery( "#radio1" ).is( jQuery( "input:checked" ) ), "Check for pseudoclass: Expected not checked" );
|
||||
|
||||
// Some raw elements
|
||||
assert.ok( jQuery( "#form" ).is( jQuery( "#qunit-fixture form" )[ 0 ] ), "Check for element: A form is a form" );
|
||||
assert.ok( !jQuery( "#form" ).is( jQuery( "div" )[ 0 ] ), "Check for element: A form is not a div" );
|
||||
assert.ok( jQuery( "#mark" ).is( jQuery( ".blog" )[ 0 ] ), "Check for class: Expected class 'blog'" );
|
||||
assert.ok( !jQuery( "#mark" ).is( jQuery( ".link" )[ 0 ] ), "Check for class: Did not expect class 'link'" );
|
||||
assert.ok( jQuery( "#simon" ).is( jQuery( ".blog.link" )[ 0 ] ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
|
||||
assert.ok( !jQuery( "#simon" ).is( jQuery( ".blogTest" )[ 0 ] ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
|
||||
} );
|
||||
|
||||
QUnit[ jQuery.find.compile ? "test" : "skip" ]( "is() with :has() selectors", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
assert.ok( jQuery( "#foo" ).is( ":has(p)" ), "Check for child: Expected a child 'p' element" );
|
||||
assert.ok( !jQuery( "#foo" ).is( ":has(ul)" ), "Check for child: Did not expect 'ul' element" );
|
||||
assert.ok( jQuery( "#foo" ).is( ":has(p):has(a):has(code)" ), "Check for childs: Expected 'p', 'a' and 'code' child elements" );
|
||||
assert.ok( !jQuery( "#foo" ).is( ":has(p):has(a):has(code):has(ol)" ), "Check for childs: Expected 'p', 'a' and 'code' child elements, but no 'ol'" );
|
||||
|
||||
assert.ok( jQuery( "#foo" ).is( jQuery( "div:has(p)" ) ), "Check for child: Expected a child 'p' element" );
|
||||
assert.ok( !jQuery( "#foo" ).is( jQuery( "div:has(ul)" ) ), "Check for child: Did not expect 'ul' element" );
|
||||
} );
|
||||
|
||||
QUnit[ jQuery.find.compile ? "test" : "skip" ]( "is() with positional selectors", function( assert ) {
|
||||
assert.expect( 27 );
|
||||
|
||||
var
|
||||
posp = jQuery(
|
||||
"<p id='posp'><a class='firsta' href='#'><em>first</em></a>" +
|
||||
"<a class='seconda' href='#'><b>test</b></a><em></em></p>"
|
||||
).appendTo( "#qunit-fixture" ),
|
||||
isit = function( sel, match, expect ) {
|
||||
assert.equal(
|
||||
jQuery( sel ).is( match ),
|
||||
expect,
|
||||
"jQuery('" + sel + "').is('" + match + "')"
|
||||
);
|
||||
};
|
||||
|
||||
isit( "#posp", "p:last", true );
|
||||
isit( "#posp", "#posp:first", true );
|
||||
isit( "#posp", "#posp:eq(2)", false );
|
||||
isit( "#posp", "#posp a:first", false );
|
||||
|
||||
isit( "#posp .firsta", "#posp a:first", true );
|
||||
isit( "#posp .firsta", "#posp a:last", false );
|
||||
isit( "#posp .firsta", "#posp a:even", true );
|
||||
isit( "#posp .firsta", "#posp a:odd", false );
|
||||
isit( "#posp .firsta", "#posp a:eq(0)", true );
|
||||
isit( "#posp .firsta", "#posp a:eq(9)", false );
|
||||
isit( "#posp .firsta", "#posp em:eq(0)", false );
|
||||
isit( "#posp .firsta", "#posp em:first", false );
|
||||
isit( "#posp .firsta", "#posp:first", false );
|
||||
|
||||
isit( "#posp .seconda", "#posp a:first", false );
|
||||
isit( "#posp .seconda", "#posp a:last", true );
|
||||
isit( "#posp .seconda", "#posp a:gt(0)", true );
|
||||
isit( "#posp .seconda", "#posp a:lt(5)", true );
|
||||
isit( "#posp .seconda", "#posp a:lt(1)", false );
|
||||
|
||||
isit( "#posp em", "#posp a:eq(0) em", true );
|
||||
isit( "#posp em", "#posp a:lt(1) em", true );
|
||||
isit( "#posp em", "#posp a:gt(1) em", false );
|
||||
isit( "#posp em", "#posp a:first em", true );
|
||||
isit( "#posp em", "#posp a em:last", true );
|
||||
isit( "#posp em", "#posp a em:eq(2)", false );
|
||||
|
||||
assert.ok( jQuery( "#option1b" ).is( "#select1 option:not(:first)" ), "POS inside of :not() (#10970)" );
|
||||
|
||||
assert.ok( jQuery( posp[ 0 ] ).is( "p:last" ), "context constructed from a single node (#13797)" );
|
||||
assert.ok( !jQuery( posp[ 0 ] ).find( "#firsta" ).is( "a:first" ), "context derived from a single node (#13797)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "index()", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
assert.equal( jQuery( "#text2" ).index(), 2, "Returns the index of a child amongst its siblings" );
|
||||
|
||||
assert.equal( jQuery( "<div/>" ).index(), -1, "Node without parent returns -1" );
|
||||
} );
|
||||
|
||||
QUnit.test( "index(Object|String|undefined)", function( assert ) {
|
||||
assert.expect( 16 );
|
||||
|
||||
var elements = jQuery( [ window, document ] ),
|
||||
inputElements = jQuery( "#radio1,#radio2,#check1,#check2" );
|
||||
|
||||
// Passing a node
|
||||
assert.equal( elements.index( window ), 0, "Check for index of elements" );
|
||||
assert.equal( elements.index( document ), 1, "Check for index of elements" );
|
||||
assert.equal( inputElements.index( document.getElementById( "radio1" ) ), 0, "Check for index of elements" );
|
||||
assert.equal( inputElements.index( document.getElementById( "radio2" ) ), 1, "Check for index of elements" );
|
||||
assert.equal( inputElements.index( document.getElementById( "check1" ) ), 2, "Check for index of elements" );
|
||||
assert.equal( inputElements.index( document.getElementById( "check2" ) ), 3, "Check for index of elements" );
|
||||
assert.equal( inputElements.index( window ), -1, "Check for not found index" );
|
||||
assert.equal( inputElements.index( document ), -1, "Check for not found index" );
|
||||
|
||||
// Passing a jQuery object
|
||||
// enabled since [5500]
|
||||
assert.equal( elements.index( elements ), 0, "Pass in a jQuery object" );
|
||||
assert.equal( elements.index( elements.eq( 1 ) ), 1, "Pass in a jQuery object" );
|
||||
assert.equal( jQuery( "#form input[type='radio']" ).index( jQuery( "#radio2" ) ), 1, "Pass in a jQuery object" );
|
||||
|
||||
// Passing a selector or nothing
|
||||
// enabled since [6330]
|
||||
assert.equal( jQuery( "#text2" ).index(), 2, "Check for index amongst siblings" );
|
||||
assert.equal( jQuery( "#form" ).children().eq( 4 ).index(), 4, "Check for index amongst siblings" );
|
||||
assert.equal( jQuery( "#radio2" ).index( "#form input[type='radio']" ), 1, "Check for index within a selector" );
|
||||
assert.equal( jQuery( "#form input[type='radio']" ).index( jQuery( "#radio2" ) ), 1, "Check for index within a selector" );
|
||||
assert.equal( jQuery( "#radio2" ).index( "#form input[type='text']" ), -1, "Check for index not found within a selector" );
|
||||
} );
|
||||
|
||||
QUnit.test( "filter(Selector|undefined)", function( assert ) {
|
||||
assert.expect( 9 );
|
||||
assert.deepEqual( jQuery( "#form input" ).filter( ":checked" ).get(), q( "radio2", "check1" ), "filter(String)" );
|
||||
assert.deepEqual( jQuery( "p" ).filter( "#ap, #sndp" ).get(), q( "ap", "sndp" ), "filter('String, String')" );
|
||||
assert.deepEqual( jQuery( "p" ).filter( "#ap,#sndp" ).get(), q( "ap", "sndp" ), "filter('String,String')" );
|
||||
|
||||
assert.deepEqual( jQuery( "p" ).filter( null ).get(), [], "filter(null) should return an empty jQuery object" );
|
||||
assert.deepEqual( jQuery( "p" ).filter( undefined ).get(), [], "filter(undefined) should return an empty jQuery object" );
|
||||
assert.deepEqual( jQuery( "p" ).filter( 0 ).get(), [], "filter(0) should return an empty jQuery object" );
|
||||
assert.deepEqual( jQuery( "p" ).filter( "" ).get(), [], "filter('') should return an empty jQuery object" );
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
var j = jQuery( "#nonnodes" ).contents();
|
||||
assert.equal( j.filter( "span" ).length, 1, "Check node,textnode,comment to filter the one span" );
|
||||
assert.equal( j.filter( "[name]" ).length, 0, "Check node,textnode,comment to filter the one span" );
|
||||
} );
|
||||
|
||||
QUnit.test( "filter(Function)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
assert.deepEqual( jQuery( "#qunit-fixture p" ).filter( function() {
|
||||
return !jQuery( "a", this ).length;
|
||||
} ).get(), q( "sndp", "first" ), "filter(Function)" );
|
||||
|
||||
assert.deepEqual( jQuery( "#qunit-fixture p" ).filter( function( i, elem ) { return !jQuery( "a", elem ).length; } ).get(), q( "sndp", "first" ), "filter(Function) using arg" );
|
||||
} );
|
||||
|
||||
QUnit.test( "filter(Element)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var element = document.getElementById( "text1" );
|
||||
assert.deepEqual( jQuery( "#form input" ).filter( element ).get(), q( "text1" ), "filter(Element)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "filter(Array)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var elements = [ document.getElementById( "text1" ) ];
|
||||
assert.deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "filter(jQuery)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var elements = jQuery( "#text1" );
|
||||
assert.deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" );
|
||||
} );
|
||||
|
||||
QUnit[ jQuery.find.compile ? "test" : "skip" ]( "filter() with positional selectors", function( assert ) {
|
||||
assert.expect( 19 );
|
||||
|
||||
var filterit = function( sel, filter, length ) {
|
||||
assert.equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" );
|
||||
};
|
||||
|
||||
jQuery( "" +
|
||||
"<p id='posp'>" +
|
||||
"<a class='firsta' href='#'>" +
|
||||
"<em>first</em>" +
|
||||
"</a>" +
|
||||
"<a class='seconda' href='#'>" +
|
||||
"<b>test</b>" +
|
||||
"</a>" +
|
||||
"<em></em>" +
|
||||
"</p>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
filterit( "#posp", "#posp:first", 1 );
|
||||
filterit( "#posp", "#posp:eq(2)", 0 );
|
||||
filterit( "#posp", "#posp a:first", 0 );
|
||||
|
||||
// Keep in mind this is within the selection and
|
||||
// not in relation to other elements (.is() is a different story)
|
||||
filterit( "#posp .firsta", "#posp a:first", 1 );
|
||||
filterit( "#posp .firsta", "#posp a:last", 1 );
|
||||
filterit( "#posp .firsta", "#posp a:last-child", 0 );
|
||||
filterit( "#posp .firsta", "#posp a:even", 1 );
|
||||
filterit( "#posp .firsta", "#posp a:odd", 0 );
|
||||
filterit( "#posp .firsta", "#posp a:eq(0)", 1 );
|
||||
filterit( "#posp .firsta", "#posp a:eq(9)", 0 );
|
||||
filterit( "#posp .firsta", "#posp em:eq(0)", 0 );
|
||||
filterit( "#posp .firsta", "#posp em:first", 0 );
|
||||
filterit( "#posp .firsta", "#posp:first", 0 );
|
||||
|
||||
filterit( "#posp .seconda", "#posp a:first", 1 );
|
||||
filterit( "#posp .seconda", "#posp em:first", 0 );
|
||||
filterit( "#posp .seconda", "#posp a:last", 1 );
|
||||
filterit( "#posp .seconda", "#posp a:gt(0)", 0 );
|
||||
filterit( "#posp .seconda", "#posp a:lt(5)", 1 );
|
||||
filterit( "#posp .seconda", "#posp a:lt(1)", 1 );
|
||||
} );
|
||||
|
||||
QUnit.test( "closest()", function( assert ) {
|
||||
assert.expect( 13 );
|
||||
|
||||
var jq;
|
||||
|
||||
assert.deepEqual( jQuery( "body" ).closest( "body" ).get(), q( "body" ), "closest(body)" );
|
||||
assert.deepEqual( jQuery( "body" ).closest( "html" ).get(), q( "html" ), "closest(html)" );
|
||||
assert.deepEqual( jQuery( "body" ).closest( "div" ).get(), [], "closest(div)" );
|
||||
assert.deepEqual( jQuery( "#qunit-fixture" ).closest( "span,#html" ).get(), q( "html" ), "closest(span,#html)" );
|
||||
|
||||
// Test .closest() limited by the context
|
||||
jq = jQuery( "#nothiddendivchild" );
|
||||
assert.deepEqual( jq.closest( "html", document.body ).get(), [], "Context limited." );
|
||||
assert.deepEqual( jq.closest( "body", document.body ).get(), [], "Context limited." );
|
||||
assert.deepEqual( jq.closest( "#nothiddendiv", document.body ).get(), q( "nothiddendiv" ), "Context not reached." );
|
||||
|
||||
//Test that .closest() returns unique'd set
|
||||
assert.equal( jQuery( "#qunit-fixture p" ).closest( "#qunit-fixture" ).length, 1, "Closest should return a unique set" );
|
||||
|
||||
// Test on disconnected node
|
||||
assert.equal( jQuery( "<div><p></p></div>" ).find( "p" ).closest( "table" ).length, 0, "Make sure disconnected closest work." );
|
||||
|
||||
// Bug #7369
|
||||
assert.equal( jQuery( "<div foo='bar'></div>" ).closest( "[foo]" ).length, 1, "Disconnected nodes with attribute selector" );
|
||||
assert.equal( jQuery( "<div>text</div>" ).closest( "[lang]" ).length, 0, "Disconnected nodes with text and non-existent attribute selector" );
|
||||
|
||||
assert.ok( !jQuery( document ).closest( "#foo" ).length, "Calling closest on a document fails silently" );
|
||||
|
||||
jq = jQuery( "<div>text</div>" );
|
||||
assert.deepEqual( jq.contents().closest( "*" ).get(), jq.get(), "Text node input (#13332)" );
|
||||
} );
|
||||
|
||||
QUnit[ jQuery.find.compile ? "test" : "skip" ]( "closest() with positional selectors", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
assert.deepEqual( jQuery( "#qunit-fixture" ).closest( "div:first" ).get(), [], "closest(div:first)" );
|
||||
assert.deepEqual( jQuery( "#qunit-fixture div" ).closest( "body:first div:last" ).get(), q( "fx-tests" ), "closest(body:first div:last)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "closest(jQuery)", function( assert ) {
|
||||
assert.expect( 8 );
|
||||
var $child = jQuery( "#nothiddendivchild" ),
|
||||
$parent = jQuery( "#nothiddendiv" ),
|
||||
$sibling = jQuery( "#foo" ),
|
||||
$body = jQuery( "body" );
|
||||
assert.ok( $child.closest( $parent ).is( "#nothiddendiv" ), "closest( jQuery('#nothiddendiv') )" );
|
||||
assert.ok( $child.closest( $parent[ 0 ] ).is( "#nothiddendiv" ), "closest( jQuery('#nothiddendiv') ) :: node" );
|
||||
assert.ok( $child.closest( $child ).is( "#nothiddendivchild" ), "child is included" );
|
||||
assert.ok( $child.closest( $child[ 0 ] ).is( "#nothiddendivchild" ), "child is included :: node" );
|
||||
assert.equal( $child.closest( document.createElement( "div" ) ).length, 0, "created element is not related" );
|
||||
assert.equal( $child.closest( $sibling ).length, 0, "Sibling not a parent of child" );
|
||||
assert.equal( $child.closest( $sibling[ 0 ] ).length, 0, "Sibling not a parent of child :: node" );
|
||||
assert.ok( $child.closest( $body.add( $parent ) ).is( "#nothiddendiv" ), "Closest ancestor retrieved." );
|
||||
} );
|
||||
|
||||
QUnit[ jQuery.find.compile ? "test" : "skip" ]( "not(Selector)", function( assert ) {
|
||||
assert.expect( 7 );
|
||||
assert.equal( jQuery( "#qunit-fixture > p#ap > a" ).not( "#google" ).length, 2, "not('selector')" );
|
||||
assert.deepEqual( jQuery( "p" ).not( ".result" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "not('.class')" );
|
||||
assert.deepEqual( jQuery( "p" ).not( "#ap, #sndp, .result" ).get(), q( "firstp", "en", "sap", "first" ), "not('selector, selector')" );
|
||||
|
||||
assert.deepEqual( jQuery( "#ap *" ).not( "code" ).get(), q( "google", "groups", "anchor1", "mark" ), "not('tag selector')" );
|
||||
assert.deepEqual( jQuery( "#ap *" ).not( "code, #mark" ).get(), q( "google", "groups", "anchor1" ), "not('tag, ID selector')" );
|
||||
assert.deepEqual( jQuery( "#ap *" ).not( "#mark, code" ).get(), q( "google", "groups", "anchor1" ), "not('ID, tag selector')" );
|
||||
|
||||
assert.deepEqual(
|
||||
jQuery( "#form option" ).not( "option.emptyopt:contains('Nothing'),optgroup *,[value='1']" ).get(),
|
||||
q( "option1c", "option1d", "option2c", "option2d", "option3c", "option3d", "option3e", "option4d", "option4e", "option5a", "option5b" ),
|
||||
"not('complex selector')"
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "not(undefined)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var all = jQuery( "p" ).get();
|
||||
assert.deepEqual( jQuery( "p" ).not( null ).get(), all, "not(null) should have no effect" );
|
||||
assert.deepEqual( jQuery( "p" ).not( undefined ).get(), all, "not(undefined) should have no effect" );
|
||||
assert.deepEqual( jQuery( "p" ).not( 0 ).get(), all, "not(0) should have no effect" );
|
||||
assert.deepEqual( jQuery( "p" ).not( "" ).get(), all, "not('') should have no effect" );
|
||||
} );
|
||||
|
||||
QUnit.test( "not(Element)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var selects = jQuery( "#form select" );
|
||||
assert.deepEqual( selects.not( selects[ 1 ] ).get(), q( "select1", "select3", "select4", "select5" ), "filter out DOM element" );
|
||||
} );
|
||||
|
||||
QUnit.test( "not(Function)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
assert.deepEqual( jQuery( "#qunit-fixture p" ).not( function() { return jQuery( "a", this ).length; } ).get(), q( "sndp", "first" ), "not(Function)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "not(Array)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
assert.equal( jQuery( "#qunit-fixture > p#ap > a" ).not( document.getElementById( "google" ) ).length, 2, "not(DOMElement)" );
|
||||
assert.equal( jQuery( "p" ).not( document.getElementsByTagName( "p" ) ).length, 0, "not(Array-like DOM collection)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "not(jQuery)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
assert.deepEqual( jQuery( "p" ).not( jQuery( "#ap, #sndp, .result" ) ).get(), q( "firstp", "en", "sap", "first" ), "not(jQuery)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "has(Element)", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
var obj, detached, multipleParent;
|
||||
|
||||
obj = jQuery( "#qunit-fixture" ).has( jQuery( "#sndp" )[ 0 ] );
|
||||
assert.deepEqual( obj.get(), q( "qunit-fixture" ), "Keeps elements that have the element as a descendant" );
|
||||
|
||||
detached = jQuery( "<a><b><i/></b></a>" );
|
||||
assert.deepEqual( detached.has( detached.find( "i" )[ 0 ] ).get(), detached.get(), "...Even when detached" );
|
||||
|
||||
multipleParent = jQuery( "#qunit-fixture, #header" ).has( jQuery( "#sndp" )[ 0 ] );
|
||||
assert.deepEqual( multipleParent.get(), q( "qunit-fixture" ), "Does not include elements that do not have the element as a descendant" );
|
||||
} );
|
||||
|
||||
QUnit.test( "has(Selector)", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var obj, detached, multipleParent, multipleHas;
|
||||
|
||||
obj = jQuery( "#qunit-fixture" ).has( "#sndp" );
|
||||
assert.deepEqual( obj.get(), q( "qunit-fixture" ), "Keeps elements that have any element matching the selector as a descendant" );
|
||||
|
||||
detached = jQuery( "<a><b><i/></b></a>" );
|
||||
assert.deepEqual( detached.has( "i" ).get(), detached.get(), "...Even when detached" );
|
||||
|
||||
multipleParent = jQuery( "#qunit-fixture, #header" ).has( "#sndp" );
|
||||
assert.deepEqual( multipleParent.get(), q( "qunit-fixture" ), "Does not include elements that do not have the element as a descendant" );
|
||||
|
||||
multipleParent = jQuery( "#select1, #select2, #select3" ).has( "#option1a, #option3a" );
|
||||
assert.deepEqual( multipleParent.get(), q( "select1", "select3" ), "Multiple contexts are checks correctly" );
|
||||
|
||||
multipleHas = jQuery( "#qunit-fixture" ).has( "#sndp, #first" );
|
||||
assert.deepEqual( multipleHas.get(), q( "qunit-fixture" ), "Only adds elements once" );
|
||||
} );
|
||||
|
||||
QUnit.test( "has(Arrayish)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var simple, detached, multipleParent, multipleHas;
|
||||
|
||||
simple = jQuery( "#qunit-fixture" ).has( jQuery( "#sndp" ) );
|
||||
assert.deepEqual( simple.get(), q( "qunit-fixture" ), "Keeps elements that have any element in the jQuery list as a descendant" );
|
||||
|
||||
detached = jQuery( "<a><b><i/></b></a>" );
|
||||
assert.deepEqual( detached.has( detached.find( "i" ) ).get(), detached.get(), "...Even when detached" );
|
||||
|
||||
multipleParent = jQuery( "#qunit-fixture, #header" ).has( jQuery( "#sndp" ) );
|
||||
assert.deepEqual( multipleParent.get(), q( "qunit-fixture" ), "Does not include elements that do not have an element in the jQuery list as a descendant" );
|
||||
|
||||
multipleHas = jQuery( "#qunit-fixture" ).has( jQuery( "#sndp, #first" ) );
|
||||
assert.deepEqual( multipleHas.get(), q( "qunit-fixture" ), "Only adds elements once" );
|
||||
} );
|
||||
|
||||
QUnit.test( "addBack()", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
assert.deepEqual( jQuery( "#en" ).siblings().addBack().get(), q( "sndp", "en", "sap" ), "Check for siblings and self" );
|
||||
assert.deepEqual( jQuery( "#foo" ).children().addBack().get(), q( "foo", "sndp", "en", "sap" ), "Check for children and self" );
|
||||
assert.deepEqual( jQuery( "#sndp, #en" ).parent().addBack().get(), q( "foo", "sndp", "en" ), "Check for parent and self" );
|
||||
assert.deepEqual( jQuery( "#groups" ).parents( "p, div" ).addBack().get(), q( "qunit-fixture", "ap", "groups" ), "Check for parents and self" );
|
||||
assert.deepEqual( jQuery( "#select1 > option" ).filter( ":first-child" ).addBack( ":last-child" ).get(), q( "option1a", "option1d" ), "Should contain the last elems plus the *filtered* prior set elements" );
|
||||
} );
|
||||
|
||||
QUnit.test( "siblings([String])", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
assert.deepEqual( jQuery( "#en" ).siblings().get(), q( "sndp", "sap" ), "Check for siblings" );
|
||||
assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).siblings().get(), q( "nonnodesElement" ), "Check for text node siblings" );
|
||||
assert.deepEqual( jQuery( "#foo" ).siblings( "form, b" ).get(), q( "form", "floatTest", "lengthtest", "name-tests", "testForm" ), "Check for multiple filters" );
|
||||
|
||||
var set = q( "sndp", "en", "sap" );
|
||||
assert.deepEqual( jQuery( "#en, #sndp" ).siblings().get(), set, "Check for unique results from siblings" );
|
||||
assert.deepEqual( jQuery( "#option5a" ).siblings( "option[data-attr]" ).get(), q( "option5c" ), "Has attribute selector in siblings (#9261)" );
|
||||
assert.equal( jQuery( "<a/>" ).siblings().length, 0, "Detached elements have no siblings (#11370)" );
|
||||
} );
|
||||
|
||||
QUnit[ jQuery.find.compile ? "test" : "skip" ]( "siblings([String])", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
assert.deepEqual( jQuery( "#sndp" ).siblings( ":has(code)" ).get(), q( "sap" ), "Check for filtered siblings (has code child element)" );
|
||||
assert.deepEqual( jQuery( "#sndp" ).siblings( ":has(a)" ).get(), q( "en", "sap" ), "Check for filtered siblings (has anchor child element)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "children([String])", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
assert.deepEqual( jQuery( "#foo" ).children().get(), q( "sndp", "en", "sap" ), "Check for children" );
|
||||
assert.deepEqual( jQuery( "#foo" ).children( "#en, #sap" ).get(), q( "en", "sap" ), "Check for multiple filters" );
|
||||
} );
|
||||
|
||||
QUnit[ jQuery.find.compile ? "test" : "skip" ]( "children([String])", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
assert.deepEqual( jQuery( "#foo" ).children( ":has(code)" ).get(), q( "sndp", "sap" ), "Check for filtered children" );
|
||||
} );
|
||||
|
||||
QUnit.test( "parent([String])", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var $el;
|
||||
|
||||
assert.equal( jQuery( "#groups" ).parent()[ 0 ].id, "ap", "Simple parent check" );
|
||||
assert.equal( jQuery( "#groups" ).parent( "p" )[ 0 ].id, "ap", "Filtered parent check" );
|
||||
assert.equal( jQuery( "#groups" ).parent( "div" ).length, 0, "Filtered parent check, no match" );
|
||||
assert.equal( jQuery( "#groups" ).parent( "div, p" )[ 0 ].id, "ap", "Check for multiple filters" );
|
||||
assert.deepEqual( jQuery( "#en, #sndp" ).parent().get(), q( "foo" ), "Check for unique results from parent" );
|
||||
|
||||
$el = jQuery( "<div>text</div>" );
|
||||
assert.deepEqual( $el.contents().parent().get(), $el.get(), "Check for parent of text node (#13265)" );
|
||||
} );
|
||||
|
||||
QUnit.test( "parents([String])", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
assert.equal( jQuery( "#groups" ).parents()[ 0 ].id, "ap", "Simple parents check" );
|
||||
assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).parents().eq( 0 ).get(), q( "nonnodes" ), "Text node parents check" );
|
||||
assert.equal( jQuery( "#groups" ).parents( "p" )[ 0 ].id, "ap", "Filtered parents check" );
|
||||
assert.equal( jQuery( "#groups" ).parents( "div" )[ 0 ].id, "qunit-fixture", "Filtered parents check2" );
|
||||
assert.deepEqual( jQuery( "#groups" ).parents( "p, div" ).get(), q( "ap", "qunit-fixture" ), "Check for multiple filters" );
|
||||
assert.deepEqual( jQuery( "#en, #sndp" ).parents().get(), q( "foo", "qunit-fixture", "dl", "body", "html" ), "Check for unique results from parents" );
|
||||
} );
|
||||
|
||||
QUnit.test( "parentsUntil([String])", function( assert ) {
|
||||
assert.expect( 10 );
|
||||
|
||||
var parents = jQuery( "#groups" ).parents();
|
||||
|
||||
assert.deepEqual( jQuery( "#groups" ).parentsUntil().get(), parents.get(), "parentsUntil with no selector (nextAll)" );
|
||||
assert.deepEqual( jQuery( "#groups" ).parentsUntil( ".foo" ).get(), parents.get(), "parentsUntil with invalid selector (nextAll)" );
|
||||
assert.deepEqual( jQuery( "#groups" ).parentsUntil( "#html" ).get(), parents.slice( 0, -1 ).get(), "Simple parentsUntil check" );
|
||||
assert.equal( jQuery( "#groups" ).parentsUntil( "#ap" ).length, 0, "Simple parentsUntil check" );
|
||||
assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).parentsUntil( "#html" ).eq( 0 ).get(), q( "nonnodes" ), "Text node parentsUntil check" );
|
||||
assert.deepEqual( jQuery( "#groups" ).parentsUntil( "#html, #body" ).get(), parents.slice( 0, 3 ).get(), "Less simple parentsUntil check" );
|
||||
assert.deepEqual( jQuery( "#groups" ).parentsUntil( "#html", "div" ).get(), jQuery( "#qunit-fixture" ).get(), "Filtered parentsUntil check" );
|
||||
assert.deepEqual( jQuery( "#groups" ).parentsUntil( "#html", "p,div,dl" ).get(), parents.slice( 0, 3 ).get(), "Multiple-filtered parentsUntil check" );
|
||||
assert.equal( jQuery( "#groups" ).parentsUntil( "#html", "span" ).length, 0, "Filtered parentsUntil check, no match" );
|
||||
assert.deepEqual( jQuery( "#groups, #ap" ).parentsUntil( "#html", "p,div,dl" ).get(), parents.slice( 0, 3 ).get(), "Multi-source, multiple-filtered parentsUntil check" );
|
||||
} );
|
||||
|
||||
QUnit.test( "next([String])", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
assert.equal( jQuery( "#ap" ).next()[ 0 ].id, "foo", "Simple next check" );
|
||||
assert.equal( jQuery( "<div>text<a id='element'></a></div>" ).contents().eq( 0 ).next().attr( "id" ), "element", "Text node next check" );
|
||||
assert.equal( jQuery( "#ap" ).next( "div" )[ 0 ].id, "foo", "Filtered next check" );
|
||||
assert.equal( jQuery( "#ap" ).next( "p" ).length, 0, "Filtered next check, no match" );
|
||||
assert.equal( jQuery( "#ap" ).next( "div, p" )[ 0 ].id, "foo", "Multiple filters" );
|
||||
assert.equal( jQuery( "body" ).next().length, 0, "Simple next check, no match" );
|
||||
} );
|
||||
|
||||
QUnit.test( "prev([String])", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
assert.equal( jQuery( "#foo" ).prev()[ 0 ].id, "ap", "Simple prev check" );
|
||||
assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).prev().get(), q( "nonnodesElement" ), "Text node prev check" );
|
||||
assert.equal( jQuery( "#foo" ).prev( "p" )[ 0 ].id, "ap", "Filtered prev check" );
|
||||
assert.equal( jQuery( "#foo" ).prev( "div" ).length, 0, "Filtered prev check, no match" );
|
||||
assert.equal( jQuery( "#foo" ).prev( "p, div" )[ 0 ].id, "ap", "Multiple filters" );
|
||||
} );
|
||||
|
||||
QUnit.test( "nextAll([String])", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var elems = jQuery( "#form" ).children();
|
||||
|
||||
assert.deepEqual( jQuery( "#label-for" ).nextAll().get(), elems.slice( 1 ).get(), "Simple nextAll check" );
|
||||
assert.equal( jQuery( "<div>text<a id='element'></a></div>" ).contents().eq( 0 ).nextAll().attr( "id" ), "element", "Text node nextAll check" );
|
||||
assert.deepEqual( jQuery( "#label-for" ).nextAll( "input" ).get(), elems.slice( 1 ).filter( "input" ).get(), "Filtered nextAll check" );
|
||||
assert.deepEqual( jQuery( "#label-for" ).nextAll( "input,select" ).get(), elems.slice( 1 ).filter( "input,select" ).get(), "Multiple-filtered nextAll check" );
|
||||
assert.deepEqual( jQuery( "#label-for, #hidden1" ).nextAll( "input,select" ).get(), elems.slice( 1 ).filter( "input,select" ).get(), "Multi-source, multiple-filtered nextAll check" );
|
||||
} );
|
||||
|
||||
QUnit.test( "prevAll([String])", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var elems = jQuery( jQuery( "#form" ).children().slice( 0, 12 ).get().reverse() );
|
||||
|
||||
assert.deepEqual( jQuery( "#area1" ).prevAll().get(), elems.get(), "Simple prevAll check" );
|
||||
assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).prevAll().get(), q( "nonnodesElement" ), "Text node prevAll check" );
|
||||
assert.deepEqual( jQuery( "#area1" ).prevAll( "input" ).get(), elems.filter( "input" ).get(), "Filtered prevAll check" );
|
||||
assert.deepEqual( jQuery( "#area1" ).prevAll( "input,select" ).get(), elems.filter( "input,select" ).get(), "Multiple-filtered prevAll check" );
|
||||
assert.deepEqual( jQuery( "#area1, #hidden1" ).prevAll( "input,select" ).get(), elems.filter( "input,select" ).get(), "Multi-source, multiple-filtered prevAll check" );
|
||||
} );
|
||||
|
||||
QUnit.test( "nextUntil([String])", function( assert ) {
|
||||
assert.expect( 12 );
|
||||
|
||||
var elems = jQuery( "#form" ).children().slice( 2, 12 );
|
||||
|
||||
assert.deepEqual( jQuery( "#text1" ).nextUntil().get(), jQuery( "#text1" ).nextAll().get(), "nextUntil with no selector (nextAll)" );
|
||||
assert.equal( jQuery( "<div>text<a id='element'></a></div>" ).contents().eq( 0 ).nextUntil().attr( "id" ), "element", "Text node nextUntil with no selector (nextAll)" );
|
||||
assert.deepEqual( jQuery( "#text1" ).nextUntil( ".foo" ).get(), jQuery( "#text1" ).nextAll().get(), "nextUntil with invalid selector (nextAll)" );
|
||||
assert.deepEqual( jQuery( "#text1" ).nextUntil( "#area1" ).get(), elems.get(), "Simple nextUntil check" );
|
||||
assert.equal( jQuery( "#text1" ).nextUntil( "#text2" ).length, 0, "Simple nextUntil check" );
|
||||
assert.deepEqual( jQuery( "#text1" ).nextUntil( "#area1, #radio1" ).get(), jQuery( "#text1" ).next().get(), "Less simple nextUntil check" );
|
||||
assert.deepEqual( jQuery( "#text1" ).nextUntil( "#area1", "input" ).get(), elems.not( "button" ).get(), "Filtered nextUntil check" );
|
||||
assert.deepEqual( jQuery( "#text1" ).nextUntil( "#area1", "button" ).get(), elems.not( "input" ).get(), "Filtered nextUntil check" );
|
||||
assert.deepEqual( jQuery( "#text1" ).nextUntil( "#area1", "button,input" ).get(), elems.get(), "Multiple-filtered nextUntil check" );
|
||||
assert.equal( jQuery( "#text1" ).nextUntil( "#area1", "div" ).length, 0, "Filtered nextUntil check, no match" );
|
||||
assert.deepEqual( jQuery( "#text1, #hidden1" ).nextUntil( "#area1", "button,input" ).get(), elems.get(), "Multi-source, multiple-filtered nextUntil check" );
|
||||
|
||||
assert.deepEqual( jQuery( "#text1" ).nextUntil( "[class=foo]" ).get(), jQuery( "#text1" ).nextAll().get(), "Non-element nodes must be skipped, since they have no attributes" );
|
||||
} );
|
||||
|
||||
QUnit.test( "prevUntil([String])", function( assert ) {
|
||||
assert.expect( 11 );
|
||||
|
||||
var elems = jQuery( "#area1" ).prevAll();
|
||||
|
||||
assert.deepEqual( jQuery( "#area1" ).prevUntil().get(), elems.get(), "prevUntil with no selector (prevAll)" );
|
||||
assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).prevUntil().get(), q( "nonnodesElement" ), "Text node prevUntil with no selector (prevAll)" );
|
||||
assert.deepEqual( jQuery( "#area1" ).prevUntil( ".foo" ).get(), elems.get(), "prevUntil with invalid selector (prevAll)" );
|
||||
assert.deepEqual( jQuery( "#area1" ).prevUntil( "label" ).get(), elems.slice( 0, -1 ).get(), "Simple prevUntil check" );
|
||||
assert.equal( jQuery( "#area1" ).prevUntil( "#button" ).length, 0, "Simple prevUntil check" );
|
||||
assert.deepEqual( jQuery( "#area1" ).prevUntil( "label, #search" ).get(), jQuery( "#area1" ).prev().get(), "Less simple prevUntil check" );
|
||||
assert.deepEqual( jQuery( "#area1" ).prevUntil( "label", "input" ).get(), elems.slice( 0, -1 ).not( "button" ).get(), "Filtered prevUntil check" );
|
||||
assert.deepEqual( jQuery( "#area1" ).prevUntil( "label", "button" ).get(), elems.slice( 0, -1 ).not( "input" ).get(), "Filtered prevUntil check" );
|
||||
assert.deepEqual( jQuery( "#area1" ).prevUntil( "label", "button,input" ).get(), elems.slice( 0, -1 ).get(), "Multiple-filtered prevUntil check" );
|
||||
assert.equal( jQuery( "#area1" ).prevUntil( "label", "div" ).length, 0, "Filtered prevUntil check, no match" );
|
||||
assert.deepEqual( jQuery( "#area1, #hidden1" ).prevUntil( "label", "button,input" ).get(), elems.slice( 0, -1 ).get(), "Multi-source, multiple-filtered prevUntil check" );
|
||||
} );
|
||||
|
||||
QUnit.test( "contents()", function( assert ) {
|
||||
assert.expect( 12 );
|
||||
var ibody, c;
|
||||
|
||||
assert.equal( jQuery( "#ap" ).contents().length, 9, "Check element contents" );
|
||||
assert.ok( jQuery( "#iframe" ).contents()[ 0 ], "Check existence of IFrame document" );
|
||||
ibody = jQuery( "#loadediframe" ).contents()[ 0 ].body;
|
||||
assert.ok( ibody, "Check existence of IFrame body" );
|
||||
|
||||
assert.equal( jQuery( "span", ibody ).text(), "span text", "Find span in IFrame and check its text" );
|
||||
|
||||
jQuery( ibody ).append( "<div>init text</div>" );
|
||||
assert.equal( jQuery( "div", ibody ).length, 2, "Check the original div and the new div are in IFrame" );
|
||||
|
||||
assert.equal( jQuery( "div", ibody ).last().text(), "init text", "Add text to div in IFrame" );
|
||||
|
||||
jQuery( "div", ibody ).last().text( "div text" );
|
||||
assert.equal( jQuery( "div", ibody ).last().text(), "div text", "Add text to div in IFrame" );
|
||||
|
||||
jQuery( "div", ibody ).last().remove();
|
||||
assert.equal( jQuery( "div", ibody ).length, 1, "Delete the div and check only one div left in IFrame" );
|
||||
|
||||
assert.equal( jQuery( "div", ibody ).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" );
|
||||
|
||||
jQuery( "<table/>", ibody ).append( "<tr><td>cell</td></tr>" ).appendTo( ibody );
|
||||
jQuery( "table", ibody ).remove();
|
||||
assert.equal( jQuery( "div", ibody ).length, 1, "Check for JS error on add and delete of a table in IFrame" );
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
c = jQuery( "#nonnodes" ).contents().contents();
|
||||
assert.equal( c.length, 1, "Check node,textnode,comment contents is just one" );
|
||||
assert.equal( c[ 0 ].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" );
|
||||
} );
|
||||
|
||||
QUnit.test( "sort direction", function( assert ) {
|
||||
assert.expect( 12 );
|
||||
|
||||
var elems = jQuery( "#ap, #select1 > *, #moretests > form" ),
|
||||
methodDirections = {
|
||||
parent: false,
|
||||
parents: true,
|
||||
parentsUntil: true,
|
||||
next: false,
|
||||
prev: false,
|
||||
nextAll: false,
|
||||
prevAll: true,
|
||||
nextUntil: false,
|
||||
prevUntil: true,
|
||||
siblings: false,
|
||||
children: false,
|
||||
contents: false
|
||||
};
|
||||
|
||||
jQuery.each( methodDirections, function( method, reversed ) {
|
||||
var actual = elems[ method ]().get(),
|
||||
forward = jQuery.uniqueSort( [].concat( actual ) );
|
||||
assert.deepEqual( actual, reversed ? forward.reverse() : forward, "Correct sort direction for " + method );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "add(String selector)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var divs;
|
||||
|
||||
assert.deepEqual(
|
||||
jQuery( "#sndp" ).add( "#en" ).add( "#sap" ).toArray(),
|
||||
q( "sndp", "en", "sap" ),
|
||||
"Check elements from document"
|
||||
);
|
||||
|
||||
divs = jQuery( "<div/>" ).add( "#sndp" );
|
||||
assert.ok( divs[ 0 ].parentNode, "Sort with the disconnected node last (started with disconnected first)." );
|
||||
} );
|
||||
|
||||
QUnit.test( "add(String selector, String context)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
assert.deepEqual(
|
||||
jQuery( [] ).add( "div", "#nothiddendiv" ).toArray(),
|
||||
q( "nothiddendivchild" ),
|
||||
"Check elements from document"
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "add(String html)", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var x,
|
||||
divs = jQuery( "#sndp" ).add( "<div/>" );
|
||||
|
||||
assert.ok( !divs[ 1 ].parentNode, "Sort with the disconnected node last." );
|
||||
|
||||
x = jQuery( [] ).add( "<p id='x1'>xxx</p>" ).add( "<p id='x2'>xxx</p>" );
|
||||
assert.equal( x[ 0 ].id, "x1", "Check detached element1" );
|
||||
assert.equal( x[ 1 ].id, "x2", "Check detached element2" );
|
||||
} );
|
||||
|
||||
QUnit.test( "add(jQuery)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var x,
|
||||
tmp = jQuery( "<div/>" );
|
||||
|
||||
x = jQuery( [] )
|
||||
.add(
|
||||
jQuery( "<p id='x1'>xxx</p>" ).appendTo( tmp )
|
||||
)
|
||||
.add(
|
||||
jQuery( "<p id='x2'>xxx</p>" ).appendTo( tmp )
|
||||
);
|
||||
|
||||
assert.equal( x[ 0 ].id, "x1", "Check element1 in detached parent" );
|
||||
assert.equal( x[ 1 ].id, "x2", "Check element2 in detached parent" );
|
||||
|
||||
x = jQuery( [] )
|
||||
.add(
|
||||
jQuery( "<p id='x1'>xxx</p>" )
|
||||
)
|
||||
.add(
|
||||
jQuery( "<p id='x2'>xxx</p>" )
|
||||
);
|
||||
|
||||
assert.equal( x[ 0 ].id, "x1", "Check detached element1" );
|
||||
assert.equal( x[ 1 ].id, "x2", "Check detached element2" );
|
||||
} );
|
||||
|
||||
QUnit.test( "add(Element)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var x,
|
||||
tmp = jQuery( "<div/>" );
|
||||
|
||||
x = jQuery( [] ).add( jQuery( "<p id='x1'>xxx</p>" ).appendTo( tmp )[ 0 ] ).add( jQuery( "<p id='x2'>xxx</p>" ).appendTo( tmp )[ 0 ] );
|
||||
assert.equal( x[ 0 ].id, "x1", "Check on-the-fly element1" );
|
||||
assert.equal( x[ 1 ].id, "x2", "Check on-the-fly element2" );
|
||||
} );
|
||||
|
||||
QUnit.test( "add(Array elements)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
assert.deepEqual(
|
||||
jQuery( "#sndp" ).add( jQuery( "#en" )[ 0 ] ).add( jQuery( "#sap" ) ).toArray(),
|
||||
q( "sndp", "en", "sap" ),
|
||||
"Check elements from document"
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "add(Window)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var frame1 = document.createElement( "iframe" ),
|
||||
frame2 = document.createElement( "iframe" );
|
||||
|
||||
// This increases window.length and sets window[i] available
|
||||
document.body.appendChild( frame1 );
|
||||
document.body.appendChild( frame2 );
|
||||
|
||||
// Window is tricky because it is a lot like an array, even Array#slice will
|
||||
// turn it into a multi-item array.
|
||||
assert.equal( jQuery( [] ).add( window ).length, 1, "Add a window" );
|
||||
|
||||
document.body.removeChild( frame1 );
|
||||
document.body.removeChild( frame2 );
|
||||
} );
|
||||
|
||||
QUnit.test( "add(NodeList|undefined|HTMLFormElement|HTMLSelectElement)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var ps, notDefined;
|
||||
|
||||
ps = document.getElementsByTagName( "p" );
|
||||
|
||||
assert.equal( jQuery( [] ).add( ps ).length, ps.length, "Add a NodeList" );
|
||||
|
||||
assert.equal( jQuery( [] ).add( notDefined ).length, 0, "Adding undefined adds nothing" );
|
||||
|
||||
assert.equal( jQuery( [] ).add( document.getElementById( "form" ) ).length, 1, "Add a form" );
|
||||
assert.equal( jQuery( [] ).add( document.getElementById( "select1" ) ).length, 1, "Add a select" );
|
||||
|
||||
// We no longer support .add(form.elements), unfortunately.
|
||||
// There is no way, in browsers, to reliably determine the difference
|
||||
// between form.elements and form - and doing .add(form) and having it
|
||||
// add the form elements is way to unexpected, so this gets the boot.
|
||||
//ok( jQuery([]).add(jQuery("#form")[0].elements).length >= 13, "Check elements from array" );
|
||||
|
||||
// For the time being, we're discontinuing support for jQuery(form.elements) since it's ambiguous in IE
|
||||
// use jQuery([]).add(form.elements) instead.
|
||||
//equal( jQuery([]).add(jQuery("#form")[0].elements).length, jQuery(jQuery("#form")[0].elements).length, "Array in constructor must equals array in add()" );
|
||||
} );
|
||||
|
||||
QUnit.test( "add(String, Context)", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
assert.deepEqual( jQuery( "#firstp" ).add( "#ap" ).get(), q( "firstp", "ap" ), "Add selector to selector " );
|
||||
assert.deepEqual( jQuery( document.getElementById( "firstp" ) ).add( "#ap" ).get(), q( "firstp", "ap" ), "Add gEBId to selector" );
|
||||
assert.deepEqual( jQuery( document.getElementById( "firstp" ) ).add( document.getElementById( "ap" ) ).get(), q( "firstp", "ap" ), "Add gEBId to gEBId" );
|
||||
|
||||
var ctx = document.getElementById( "firstp" );
|
||||
assert.deepEqual( jQuery( "#firstp" ).add( "#ap", ctx ).get(), q( "firstp" ), "Add selector to selector " );
|
||||
assert.deepEqual( jQuery( document.getElementById( "firstp" ) ).add( "#ap", ctx ).get(), q( "firstp" ), "Add gEBId to selector, not in context" );
|
||||
assert.deepEqual( jQuery( document.getElementById( "firstp" ) ).add( "#ap", document.getElementsByTagName( "body" )[ 0 ] ).get(), q( "firstp", "ap" ), "Add gEBId to selector, in context" );
|
||||
} );
|
||||
|
||||
QUnit.test( "eq('-1') #10616", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
var $divs = jQuery( "div" );
|
||||
|
||||
assert.equal( $divs.eq( -1 ).length, 1, "The number -1 returns a selection that has length 1" );
|
||||
assert.equal( $divs.eq( "-1" ).length, 1, "The string '-1' returns a selection that has length 1" );
|
||||
assert.deepEqual( $divs.eq( "-1" ), $divs.eq( -1 ), "String and number -1 match" );
|
||||
} );
|
||||
|
||||
QUnit.test( "index(no arg) #10977", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var $list, fragment, div;
|
||||
|
||||
$list = jQuery( "<ul id='indextest'><li class='zero'>THIS ONE</li><li class='one'>a</li><li class='two'>b</li><li class='three'>c</li></ul>" );
|
||||
jQuery( "#qunit-fixture" ).append( $list );
|
||||
assert.strictEqual( jQuery( "#indextest li.zero" ).first().index(), 0, "No Argument Index Check" );
|
||||
$list.remove();
|
||||
|
||||
fragment = document.createDocumentFragment();
|
||||
div = fragment.appendChild( document.createElement( "div" ) );
|
||||
|
||||
assert.equal( jQuery( div ).index(), 0, "If jQuery#index called on element whose parent is fragment, it still should work correctly" );
|
||||
} );
|
||||
|
||||
QUnit.test( "traversing non-elements with attribute filters (#12523)", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var nonnodes = jQuery( "#nonnodes" ).contents();
|
||||
|
||||
assert.equal( nonnodes.filter( "[id]" ).length, 1, ".filter" );
|
||||
assert.equal( nonnodes.find( "[id]" ).length, 0, ".find" );
|
||||
assert.strictEqual( nonnodes.is( "[id]" ), true, ".is" );
|
||||
assert.deepEqual( nonnodes.closest( "[id='nonnodes']" ).get(), q( "nonnodes" ), ".closest" );
|
||||
assert.deepEqual( nonnodes.parents( "[id='nonnodes']" ).get(), q( "nonnodes" ), ".parents" );
|
||||
} );
|
443
dashboard-ui/bower_components/jquery/test/unit/wrap.js
vendored
Normal file
443
dashboard-ui/bower_components/jquery/test/unit/wrap.js
vendored
Normal file
|
@ -0,0 +1,443 @@
|
|||
( function() {
|
||||
|
||||
if ( !jQuery.fn.wrap ) { // no wrap module
|
||||
return;
|
||||
}
|
||||
|
||||
QUnit.module( "wrap", {
|
||||
teardown: moduleTeardown
|
||||
} );
|
||||
|
||||
// See test/unit/manipulation.js for explanation about these 2 functions
|
||||
function manipulationBareObj( value ) {
|
||||
return value;
|
||||
}
|
||||
|
||||
function manipulationFunctionReturningObj( value ) {
|
||||
return function() {
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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"
|
||||
);
|
||||
|
||||
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();
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
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"
|
||||
);
|
||||
|
||||
// Try wrapping a disconnected node
|
||||
cacheLength = 0;
|
||||
for ( i in jQuery.cache ) {
|
||||
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"
|
||||
);
|
||||
|
||||
for ( i in jQuery.cache ) {
|
||||
cacheLength--;
|
||||
}
|
||||
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."
|
||||
);
|
||||
|
||||
// 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."
|
||||
);
|
||||
|
||||
// Wrap an element with a jQuery set
|
||||
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."
|
||||
);
|
||||
|
||||
// Remove handlers on detached elements
|
||||
result.off();
|
||||
jQuery( this ).off();
|
||||
} );
|
||||
|
||||
j = jQuery( "<span/>" ).wrap( result );
|
||||
assert.equal(
|
||||
j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works."
|
||||
);
|
||||
|
||||
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" );
|
||||
|
||||
assert.expect( targets.length );
|
||||
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" );
|
||||
|
||||
assert.expect( targets.length * 2 );
|
||||
targets.wrap( "<div class='wrapper'></div>" );
|
||||
|
||||
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"
|
||||
);
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapAll(String)", function( assert ) {
|
||||
|
||||
assert.expect( 5 );
|
||||
|
||||
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>" );
|
||||
|
||||
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(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" ) );
|
||||
|
||||
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 ) {
|
||||
|
||||
assert.expect( 6 );
|
||||
|
||||
var num;
|
||||
|
||||
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"
|
||||
);
|
||||
|
||||
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/>" );
|
||||
|
||||
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."
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "wrapInner(Function) returns String", function( assert ) {
|
||||
|
||||
assert.expect( 6 );
|
||||
|
||||
var num,
|
||||
val = manipulationFunctionReturningObj;
|
||||
|
||||
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"
|
||||
);
|
||||
|
||||
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 ) {
|
||||
|
||||
assert.expect( 5 );
|
||||
|
||||
var num,
|
||||
val = manipulationFunctionReturningObj,
|
||||
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"
|
||||
);
|
||||
|
||||
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>"
|
||||
);
|
||||
|
||||
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.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( "#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( "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"
|
||||
);
|
||||
|
||||
jQuery( "body > span.unwrap" ).remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", function( assert ) {
|
||||
|
||||
assert.expect( 2 );
|
||||
|
||||
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>" );
|
||||
|
||||
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;";
|
||||
|
||||
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( script ).remove();
|
||||
} );
|
||||
|
||||
} )();
|
Loading…
Add table
Add a link
Reference in a new issue