third batch

1.7/enhancement_8685
louisremi 2011-04-12 10:47:46 +02:00
parent 11adde5127
commit f42010b657
7 changed files with 615 additions and 615 deletions

View File

@ -34,7 +34,7 @@ function testWidth( val ) {
equals( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
equals( blah.width(), null, "Make sure 'null' is returned on an empty set");
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
}
test("width()", function() {
@ -83,7 +83,7 @@ function testHeight( val ) {
equals( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
equals( blah.height(), null, "Make sure 'null' is returned on an empty set");
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
}
test("height()", function() {
@ -132,7 +132,7 @@ test("innerWidth()", function() {
equals( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
});
test("innerHeight()", function() {
@ -161,7 +161,7 @@ test("innerHeight()", function() {
equals( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
});
test("outerWidth()", function() {
@ -191,7 +191,7 @@ test("outerWidth()", function() {
equals( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
});
test("outerHeight()", function() {
@ -220,5 +220,5 @@ test("outerHeight()", function() {
equals( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
jQuery.removeData($div[0], 'olddisplay', true);
jQuery.removeData($div[0], "olddisplay", true);
});

96
test/unit/effects.js vendored
View File

@ -62,7 +62,7 @@ test("show()", function() {
});
// #show-tests * is set display: none in CSS
jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id="test-table"></table>');
jQuery("#main").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
var old = jQuery("#test-table").show().css("display") !== "table";
jQuery("#test-table").remove();
@ -96,7 +96,7 @@ test("show(Number) - other displays", function() {
stop();
// #show-tests * is set display: none in CSS
jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id="test-table"></table>');
jQuery("#main").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
var old = jQuery("#test-table").show().css("display") !== "table",
num = 0;
@ -138,11 +138,11 @@ test("Persist correct display value", function() {
stop();
// #show-tests * is set display: none in CSS
jQuery("#main").append('<div id="show-tests"><span style="position:absolute;">foo</span></div>');
jQuery("#main").append("<div id='show-tests'><span style='position:absolute;'>foo</span></div>");
var $span = jQuery("#show-tests span"),
displayNone = $span.css("display"),
display = '', num = 0;
display = "", num = 0;
$span.show();
@ -165,10 +165,10 @@ test("Persist correct display value", function() {
test("animate(Hash, Object, Function)", function() {
expect(1);
stop();
var hash = {opacity: 'show'};
var hash = {opacity: "show"};
var hashCopy = jQuery.extend({}, hash);
jQuery('#foo').animate(hash, 0, function() {
equals( hash.opacity, hashCopy.opacity, 'Check if animate changed the hash parameter' );
jQuery("#foo").animate(hash, 0, function() {
equals( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" );
start();
});
});
@ -193,7 +193,7 @@ test("animate block as inline width/height", function() {
if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
stop();
jQuery("#foo").css({ display: "inline", width: '', height: '' }).animate({ width: 42, height: 42 }, 100, function() {
jQuery("#foo").css({ display: "inline", width: "", height: "" }).animate({ width: 42, height: 42 }, 100, function() {
equals( jQuery(this).css("display"), jQuery.support.inlineBlockNeedsLayout ? "inline" : "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
equals( this.offsetWidth, 42, "width was animated" );
equals( this.offsetHeight, 42, "height was animated" );
@ -218,9 +218,9 @@ test("animate native inline width/height", function() {
if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
stop();
jQuery("#foo").css({ display: "", width: '', height: '' })
.append('<span>text</span>')
.children('span')
jQuery("#foo").css({ display: "", width: "", height: "" })
.append("<span>text</span>")
.children("span")
.animate({ width: 42, height: 42 }, 100, function() {
equals( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
equals( this.offsetWidth, 42, "width was animated" );
@ -317,13 +317,13 @@ test("animate option (queue === false)", function () {
var order = [];
var $foo = jQuery("#foo");
$foo.animate({width:'100px'}, 3000, function () {
$foo.animate({width:"100px"}, 3000, function () {
// should finish after unqueued animation so second
order.push(2);
same( order, [ 1, 2 ], "Animations finished in the correct order" );
start();
});
$foo.animate({fontSize:'2em'}, {queue:false, duration:10, complete:function () {
$foo.animate({fontSize:"2em"}, {queue:false, duration:10, complete:function () {
// short duration and out of queue so should finish first
order.push(1);
}});
@ -433,7 +433,7 @@ test("stop()", function() {
var w = 0;
$foo.hide().width(200).width();
$foo.animate({ width:'show' }, 1000);
$foo.animate({ width: "show" }, 1000);
setTimeout(function(){
var nw = $foo.width();
notEqual( nw, w, "An animation occurred " + nw + "px " + w + "px");
@ -458,9 +458,9 @@ test("stop() - several in queue", function() {
var w = 0;
$foo.hide().width(200).width();
$foo.animate({ width:'show' }, 1000);
$foo.animate({ width:'hide' }, 1000);
$foo.animate({ width:'show' }, 1000);
$foo.animate({ width: "show" }, 1000);
$foo.animate({ width: "hide" }, 1000);
$foo.animate({ width: "show" }, 1000);
setTimeout(function(){
equals( $foo.queue().length, 3, "All 3 still in the queue" );
var nw = $foo.width();
@ -483,9 +483,9 @@ test("stop(clearQueue)", function() {
var w = 0;
$foo.hide().width(200).width();
$foo.animate({ width:'show' }, 1000);
$foo.animate({ width:'hide' }, 1000);
$foo.animate({ width:'show' }, 1000);
$foo.animate({ width: "show" }, 1000);
$foo.animate({ width: "hide" }, 1000);
$foo.animate({ width: "show" }, 1000);
setTimeout(function(){
var nw = $foo.width();
ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
@ -510,10 +510,10 @@ test("stop(clearQueue, gotoEnd)", function() {
var w = 0;
$foo.hide().width(200).width();
$foo.animate({ width:'show' }, 1000);
$foo.animate({ width:'hide' }, 1000);
$foo.animate({ width:'show' }, 1000);
$foo.animate({ width:'hide' }, 1000);
$foo.animate({ width: "show" }, 1000);
$foo.animate({ width: "hide" }, 1000);
$foo.animate({ width: "show" }, 1000);
$foo.animate({ width: "hide" }, 1000);
setTimeout(function(){
var nw = $foo.width();
ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
@ -783,7 +783,7 @@ jQuery.each( {
});
jQuery.fn.saveState = function(hiddenOverflow){
var check = ['opacity','height','width','display','overflow'];
var check = ["opacity", "height", "width", "display", "overflow"];
expect(check.length);
stop();
@ -804,64 +804,64 @@ jQuery.checkState = function(){
});
// manually clean data on modified element
jQuery.removeData(this, 'olddisplay', true);
jQuery.removeData(this, "olddisplay", true);
start();
}
// Chaining Tests
test("Chain fadeOut fadeIn", function() {
jQuery('#fadein div').saveState().fadeOut('fast').fadeIn('fast',jQuery.checkState);
jQuery("#fadein div").saveState().fadeOut("fast").fadeIn("fast",jQuery.checkState);
});
test("Chain fadeIn fadeOut", function() {
jQuery('#fadeout div').saveState().fadeIn('fast').fadeOut('fast',jQuery.checkState);
jQuery("#fadeout div").saveState().fadeIn("fast").fadeOut("fast",jQuery.checkState);
});
test("Chain hide show", function() {
jQuery('#show div').saveState(jQuery.support.shrinkWrapBlocks).hide('fast').show('fast',jQuery.checkState);
jQuery("#show div").saveState(jQuery.support.shrinkWrapBlocks).hide("fast").show("fast",jQuery.checkState);
});
test("Chain show hide", function() {
jQuery('#hide div').saveState(jQuery.support.shrinkWrapBlocks).show('fast').hide('fast',jQuery.checkState);
jQuery("#hide div").saveState(jQuery.support.shrinkWrapBlocks).show("fast").hide("fast",jQuery.checkState);
});
test("Chain show hide with easing and callback", function() {
jQuery('#hide div').saveState().show('fast').hide('fast','linear',jQuery.checkState);
jQuery("#hide div").saveState().show("fast").hide("fast","linear",jQuery.checkState);
});
test("Chain toggle in", function() {
jQuery('#togglein div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast',jQuery.checkState);
jQuery("#togglein div").saveState(jQuery.support.shrinkWrapBlocks).toggle("fast").toggle("fast",jQuery.checkState);
});
test("Chain toggle out", function() {
jQuery('#toggleout div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast',jQuery.checkState);
jQuery("#toggleout div").saveState(jQuery.support.shrinkWrapBlocks).toggle("fast").toggle("fast",jQuery.checkState);
});
test("Chain toggle out with easing and callback", function() {
jQuery('#toggleout div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast','linear',jQuery.checkState);
jQuery("#toggleout div").saveState(jQuery.support.shrinkWrapBlocks).toggle("fast").toggle("fast","linear",jQuery.checkState);
});
test("Chain slideDown slideUp", function() {
jQuery('#slidedown div').saveState(jQuery.support.shrinkWrapBlocks).slideDown('fast').slideUp('fast',jQuery.checkState);
jQuery("#slidedown div").saveState(jQuery.support.shrinkWrapBlocks).slideDown("fast").slideUp("fast",jQuery.checkState);
});
test("Chain slideUp slideDown", function() {
jQuery('#slideup div').saveState(jQuery.support.shrinkWrapBlocks).slideUp('fast').slideDown('fast',jQuery.checkState);
jQuery("#slideup div").saveState(jQuery.support.shrinkWrapBlocks).slideUp("fast").slideDown("fast",jQuery.checkState);
});
test("Chain slideUp slideDown with easing and callback", function() {
jQuery('#slideup div').saveState(jQuery.support.shrinkWrapBlocks).slideUp('fast').slideDown('fast','linear',jQuery.checkState);
jQuery("#slideup div").saveState(jQuery.support.shrinkWrapBlocks).slideUp("fast").slideDown("fast","linear",jQuery.checkState);
});
test("Chain slideToggle in", function() {
jQuery('#slidetogglein div').saveState(jQuery.support.shrinkWrapBlocks).slideToggle('fast').slideToggle('fast',jQuery.checkState);
jQuery("#slidetogglein div").saveState(jQuery.support.shrinkWrapBlocks).slideToggle("fast").slideToggle("fast",jQuery.checkState);
});
test("Chain slideToggle out", function() {
jQuery('#slidetoggleout div').saveState(jQuery.support.shrinkWrapBlocks).slideToggle('fast').slideToggle('fast',jQuery.checkState);
jQuery("#slidetoggleout div").saveState(jQuery.support.shrinkWrapBlocks).slideToggle("fast").slideToggle("fast",jQuery.checkState);
});
test("Chain fadeToggle in", function() {
jQuery('#fadetogglein div').saveState().fadeToggle('fast').fadeToggle('fast',jQuery.checkState);
jQuery("#fadetogglein div").saveState().fadeToggle("fast").fadeToggle("fast",jQuery.checkState);
});
test("Chain fadeToggle out", function() {
jQuery('#fadetoggleout div').saveState().fadeToggle('fast').fadeToggle('fast',jQuery.checkState);
jQuery("#fadetoggleout div").saveState().fadeToggle("fast").fadeToggle("fast",jQuery.checkState);
});
test("Chain fadeTo 0.5 1.0 with easing and callback)", function() {
jQuery('#fadeto div').saveState().fadeTo('fast',0.5).fadeTo('fast',1.0,'linear',jQuery.checkState);
jQuery("#fadeto div").saveState().fadeTo("fast",0.5).fadeTo("fast",1.0,"linear",jQuery.checkState);
});
jQuery.makeTest = function( text ){
@ -903,23 +903,23 @@ test("animate with per-property easing", function(){
var _test2_called = false;
var _default_test_called = false;
jQuery.easing['_test1'] = function() {
jQuery.easing["_test1"] = function() {
_test1_called = true;
};
jQuery.easing['_test2'] = function() {
jQuery.easing["_test2"] = function() {
_test2_called = true;
};
jQuery.easing['_default_test'] = function() {
jQuery.easing["_default_test"] = function() {
_default_test_called = true;
};
jQuery({a:0,b:0,c:0}).animate({
a: [100, '_test1'],
b: [100, '_test2'],
a: [100, "_test1"],
b: [100, "_test2"],
c: 100
}, 400, '_default_test', function(){
}, 400, "_default_test", function(){
start();
ok(_test1_called, "Easing function (1) called");
ok(_test2_called, "Easing function (2) called");

View File

@ -305,7 +305,7 @@ test("bind/delegate bubbling, isDefaultPrevented", function() {
fakeClick = function($jq) {
// Use a native click so we don't get jQuery simulated bubbling
if ( document.createEvent ) {
var e = document.createEvent( 'MouseEvents' );
var e = document.createEvent( "MouseEvents" );
e.initEvent( "click", true, true );
$jq[0].dispatchEvent(e);
}
@ -347,7 +347,7 @@ test("bind(), iframes", function() {
jQuery("div", doc).bind("click", function() {
ok( true, "Binding to element inside iframe" );
}).click().unbind('click');
}).click().unbind("click");
});
test("bind(), trigger change on select", function() {
@ -357,8 +357,8 @@ test("bind(), trigger change on select", function() {
equals( event.data, counter++, "Event.data is not a global event object" );
};
jQuery("#form select").each(function(i){
jQuery(this).bind('change', i, selectOnChange);
}).trigger('change');
jQuery(this).bind("change", i, selectOnChange);
}).trigger("change");
});
test("bind(), namespaced events, cloned events", 18, function() {
@ -646,23 +646,23 @@ test("unbind(type)", function() {
}
message = "unbind passing function";
$elem.bind('error1', error).unbind('error1',error).triggerHandler('error1');
$elem.bind("error1", error).unbind("error1", error).triggerHandler("error1");
message = "unbind all from event";
$elem.bind('error1', error).unbind('error1').triggerHandler('error1');
$elem.bind("error1", error).unbind("error1").triggerHandler("error1");
message = "unbind all";
$elem.bind('error1', error).unbind().triggerHandler('error1');
$elem.bind("error1", error).unbind().triggerHandler("error1");
message = "unbind many with function";
$elem.bind('error1 error2',error)
.unbind('error1 error2', error )
.trigger('error1').triggerHandler('error2');
$elem.bind("error1 error2",error)
.unbind("error1 error2", error )
.trigger("error1").triggerHandler("error2");
message = "unbind many"; // #3538
$elem.bind('error1 error2',error)
.unbind('error1 error2')
.trigger('error1').triggerHandler('error2');
$elem.bind("error1 error2", error)
.unbind("error1 error2")
.trigger("error1").triggerHandler("error2");
message = "unbind without a type or handler";
$elem.bind("error1 error2.test",error)
@ -678,28 +678,28 @@ test("unbind(eventObject)", function() {
function assert( expected ){
num = 0;
$elem.trigger('foo').triggerHandler('bar');
$elem.trigger("foo").triggerHandler("bar");
equals( num, expected, "Check the right handlers are triggered" );
}
$elem
// This handler shouldn't be unbound
.bind('foo', function(){
.bind("foo", function(){
num += 1;
})
.bind('foo', function(e){
.bind("foo", function(e){
$elem.unbind( e )
num += 2;
})
// Neither this one
.bind('bar', function(){
.bind("bar", function(){
num += 4;
});
assert( 7 );
assert( 5 );
$elem.unbind('bar');
$elem.unbind("bar");
assert( 1 );
$elem.unbind();
@ -732,7 +732,7 @@ test("mouseover triggers mouseenter", function() {
elem.mouseenter(function () {
count++;
});
elem.trigger('mouseover');
elem.trigger("mouseover");
equals(count, 1, "make sure mouseover triggers a mouseenter" );
elem.remove();
@ -741,9 +741,9 @@ test("mouseover triggers mouseenter", function() {
test("trigger() shortcuts", function() {
expect(6);
var elem = jQuery('<li><a href="#">Change location</a></li>').prependTo('#firstUL');
elem.find('a').bind('click', function() {
var close = jQuery('spanx', this); // same with jQuery(this).find('span');
var elem = jQuery("<li><a href='#'>Change location</a></li>").prependTo("#firstUL");
elem.find("a").bind("click", function() {
var close = jQuery("spanx", this); // same with jQuery(this).find("span");
equals( close.length, 0, "Context element does not exist, length must be zero" );
ok( !close[0], "Context element does not exist, direct access to element must return undefined" );
return false;
@ -757,20 +757,20 @@ test("trigger() shortcuts", function() {
}).click();
var counter = 0;
jQuery('#firstp')[0].onclick = function(event) {
jQuery("#firstp")[0].onclick = function(event) {
counter++;
};
jQuery('#firstp').click();
jQuery("#firstp").click();
equals( counter, 1, "Check that click, triggers onclick event handler also" );
var clickCounter = 0;
jQuery('#simon1')[0].onclick = function(event) {
jQuery("#simon1")[0].onclick = function(event) {
clickCounter++;
};
jQuery('#simon1').click();
jQuery("#simon1").click();
equals( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );
elem = jQuery('<img />').load(function(){
elem = jQuery("<img />").load(function(){
ok( true, "Trigger the load event, using the shortcut .load() (#2819)");
}).load();
@ -853,7 +853,7 @@ test("trigger(type, [data], [fn])", function() {
var pass = true;
try {
jQuery('#form input:first').hide().trigger('focus');
jQuery("#form input:first").hide().trigger("focus");
} catch(e) {
pass = false;
}
@ -861,7 +861,7 @@ test("trigger(type, [data], [fn])", function() {
pass = true;
try {
jQuery('#main table:first').bind('test:test', function(){}).trigger('test:test');
jQuery("#main table:first").bind("test:test", function(){}).trigger("test:test");
} catch (e) {
pass = false;
}
@ -899,8 +899,8 @@ test("jQuery.Event.currentTarget", function(){
test("trigger(eventObject, [data], [fn])", function() {
expect(25);
var $parent = jQuery('<div id="par" />').hide().appendTo('body'),
$child = jQuery('<p id="child">foo</p>').appendTo( $parent );
var $parent = jQuery("<div id='par' />").hide().appendTo("body"),
$child = jQuery("<p id='child'>foo</p>").appendTo( $parent );
var event = jQuery.Event("noNew");
ok( event != window, "Instantiate jQuery.Event without the 'new' keyword" );
@ -920,21 +920,21 @@ test("trigger(eventObject, [data], [fn])", function() {
equals( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
equals( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );
$parent.bind('foo',function(e){
$parent.bind("foo",function(e){
// Tries bubbling
equals( e.type, 'foo', 'Verify event type when passed passing an event object' );
equals( e.target.id, 'child', 'Verify event.target when passed passing an event object' );
equals( e.currentTarget.id, 'par', 'Verify event.target when passed passing an event object' );
equals( e.secret, 'boo!', 'Verify event object\'s custom attribute when passed passing an event object' );
equals( e.type, "foo", "Verify event type when passed passing an event object" );
equals( e.target.id, "child", "Verify event.target when passed passing an event object" );
equals( e.currentTarget.id, "par", "Verify event.target when passed passing an event object" );
equals( e.secret, "boo!", "Verify event object's custom attribute when passed passing an event object" );
});
// test with an event object
event = new jQuery.Event("foo");
event.secret = 'boo!';
event.secret = "boo!";
$child.trigger(event);
// test with a literal object
$child.trigger({type:'foo', secret:'boo!'});
$child.trigger({type: "foo", secret: "boo!"});
$parent.unbind();
@ -942,9 +942,9 @@ test("trigger(eventObject, [data], [fn])", function() {
ok( false, "This assertion shouldn't be reached");
}
$parent.bind('foo', error );
$parent.bind("foo", error );
$child.bind('foo',function(e, a, b, c ){
$child.bind("foo",function(e, a, b, c ){
equals( arguments.length, 4, "Check arguments length");
equals( a, 1, "Check first custom argument");
equals( b, 2, "Check second custom argument");
@ -962,14 +962,14 @@ test("trigger(eventObject, [data], [fn])", function() {
// We should add this back in when we want to test the order
// in which event handlers are iterated.
//$child.bind('foo', error );
//$child.bind("foo", error );
event = new jQuery.Event("foo");
$child.trigger( event, [1,2,3] ).unbind();
equals( event.result, "result", "Check event.result attribute");
// Will error if it bubbles
$child.triggerHandler('foo');
$child.triggerHandler("foo");
$child.unbind();
$parent.unbind().remove();
@ -1000,12 +1000,12 @@ test("jQuery.Event.currentTarget", function(){
expect(1);
var counter = 0,
$elem = jQuery('<button>a</button>').click(function(e){
$elem = jQuery("<button>a</button>").click(function(e){
equals( e.currentTarget, this, "Check currentTarget on "+(counter++?"native":"fake") +" event" );
});
// Fake event
$elem.trigger('click');
$elem.trigger("click");
// Cleanup
$elem.unbind();
@ -1018,7 +1018,7 @@ test("toggle(Function, Function, ...)", function() {
fn1 = function(e) { count++; },
fn2 = function(e) { count--; },
preventDefault = function(e) { e.preventDefault() },
link = jQuery('#mark');
link = jQuery("#mark");
link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();
equals( count, 1, "Check for toggle(fn, fn)" );
@ -1062,8 +1062,8 @@ test("toggle(Function, Function, ...)", function() {
$div.click();
equals( turn, 2, "Trying toggle with 3 functions, attempt 5 yields 2");
$div.unbind('click',fns[0]);
var data = jQuery._data( $div[0], 'events' );
$div.unbind("click",fns[0]);
var data = jQuery._data( $div[0], "events" );
ok( !data, "Unbinding one function from toggle unbinds them all");
// manually clean up detached elements
@ -1178,12 +1178,12 @@ test(".live()/.die()", function() {
jQuery("div").die("submit");
// Test binding with a different context
var clicked = 0, container = jQuery('#main')[0];
var clicked = 0, container = jQuery("#main")[0];
jQuery("#foo", container).live("click", function(e){ clicked++; });
jQuery("div").trigger('click');
jQuery("#foo").trigger('click');
jQuery("#main").trigger('click');
jQuery("body").trigger('click');
jQuery("div").trigger("click");
jQuery("#foo").trigger("click");
jQuery("#main").trigger("click");
jQuery("body").trigger("click");
equals( clicked, 2, "live with a context" );
// Make sure the event is actually stored on the context
@ -1191,7 +1191,7 @@ test(".live()/.die()", function() {
// Test unbinding with a different context
jQuery("#foo", container).die("click");
jQuery("#foo").trigger('click');
jQuery("#foo").trigger("click");
equals( clicked, 2, "die with a context");
// Test binding with event data
@ -1273,9 +1273,9 @@ test(".live()/.die()", function() {
// Make sure we don't loose the target by DOM modifications
// after the bubble already reached the liveHandler
var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('<span></span>').get(0);
var livec = 0, elemDiv = jQuery("#nothiddendivchild").html("<span></span>").get(0);
jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(''); });
jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(""); });
jQuery("#nothiddendivchild").live("click", function(e){ if(e.target) {livec++;} });
jQuery("#nothiddendiv span").click();
@ -1290,20 +1290,20 @@ test(".live()/.die()", function() {
var lived = 0, livee = 0;
// bind one pair in one order
jQuery('span#liveSpan1 a').live('click', function(){ lived++; return false; });
jQuery('span#liveSpan1').live('click', function(){ livee++; });
jQuery("span#liveSpan1 a").live("click", function(){ lived++; return false; });
jQuery("span#liveSpan1").live("click", function(){ livee++; });
jQuery('span#liveSpan1 a').click();
jQuery("span#liveSpan1 a").click();
equals( lived, 1, "Verify that only one first handler occurred." );
equals( livee, 0, "Verify that second handler doesn't." );
// and one pair in inverse
jQuery('span#liveSpan2').live('click', function(){ livee++; });
jQuery('span#liveSpan2 a').live('click', function(){ lived++; return false; });
jQuery("span#liveSpan2").live("click", function(){ livee++; });
jQuery("span#liveSpan2 a").live("click", function(){ lived++; return false; });
lived = 0;
livee = 0;
jQuery('span#liveSpan2 a').click();
jQuery("span#liveSpan2 a").click();
equals( lived, 1, "Verify that only one first handler occurred." );
equals( livee, 0, "Verify that second handler doesn't." );
@ -1314,15 +1314,15 @@ test(".live()/.die()", function() {
jQuery("span#liveSpan2").die("click");
// Test this, target and currentTarget are correct
jQuery('span#liveSpan1').live('click', function(e){
equals( this.id, 'liveSpan1', 'Check the this within a live handler' );
equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a live handler' );
equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a live handler' );
jQuery("span#liveSpan1").live("click", function(e){
equals( this.id, "liveSpan1", "Check the this within a live handler" );
equals( e.currentTarget.id, "liveSpan1", "Check the event.currentTarget within a live handler" );
equals( e.target.nodeName.toUpperCase(), "A", "Check the event.target within a live handler" );
});
jQuery('span#liveSpan1 a').click();
jQuery("span#liveSpan1 a").click();
jQuery('span#liveSpan1').die('click');
jQuery("span#liveSpan1").die("click");
// Work with deep selectors
livee = 0;
@ -1705,12 +1705,12 @@ test(".delegate()/.undelegate()", function() {
jQuery("#body").undelegate("div", "submit");
// Test binding with a different context
var clicked = 0, container = jQuery('#main')[0];
var clicked = 0, container = jQuery("#main")[0];
jQuery("#main").delegate("#foo", "click", function(e){ clicked++; });
jQuery("div").trigger('click');
jQuery("#foo").trigger('click');
jQuery("#main").trigger('click');
jQuery("body").trigger('click');
jQuery("div").trigger("click");
jQuery("#foo").trigger("click");
jQuery("#main").trigger("click");
jQuery("body").trigger("click");
equals( clicked, 2, "delegate with a context" );
// Make sure the event is actually stored on the context
@ -1718,7 +1718,7 @@ test(".delegate()/.undelegate()", function() {
// Test unbinding with a different context
jQuery("#main").undelegate("#foo", "click");
jQuery("#foo").trigger('click');
jQuery("#foo").trigger("click");
equals( clicked, 2, "undelegate with a context");
// Test binding with event data
@ -1804,9 +1804,9 @@ test(".delegate()/.undelegate()", function() {
// Make sure we don't loose the target by DOM modifications
// after the bubble already reached the liveHandler
var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('<span></span>').get(0);
var livec = 0, elemDiv = jQuery("#nothiddendivchild").html("<span></span>").get(0);
jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ jQuery("#nothiddendivchild").html(''); });
jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ jQuery("#nothiddendivchild").html(""); });
jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ if(e.target) {livec++;} });
jQuery("#nothiddendiv span").click();
@ -1821,20 +1821,20 @@ test(".delegate()/.undelegate()", function() {
var lived = 0, livee = 0;
// bind one pair in one order
jQuery("#body").delegate('span#liveSpan1 a', 'click', function(){ lived++; return false; });
jQuery("#body").delegate('span#liveSpan1', 'click', function(){ livee++; });
jQuery("#body").delegate("span#liveSpan1 a", "click", function(){ lived++; return false; });
jQuery("#body").delegate("span#liveSpan1", "click", function(){ livee++; });
jQuery('span#liveSpan1 a').click();
jQuery("span#liveSpan1 a").click();
equals( lived, 1, "Verify that only one first handler occurred." );
equals( livee, 0, "Verify that second handler doesn't." );
// and one pair in inverse
jQuery("#body").delegate('span#liveSpan2', 'click', function(){ livee++; });
jQuery("#body").delegate('span#liveSpan2 a', 'click', function(){ lived++; return false; });
jQuery("#body").delegate("span#liveSpan2", "click", function(){ livee++; });
jQuery("#body").delegate("span#liveSpan2 a", "click", function(){ lived++; return false; });
lived = 0;
livee = 0;
jQuery('span#liveSpan2 a').click();
jQuery("span#liveSpan2 a").click();
equals( lived, 1, "Verify that only one first handler occurred." );
equals( livee, 0, "Verify that second handler doesn't." );
@ -1842,15 +1842,15 @@ test(".delegate()/.undelegate()", function() {
jQuery("#body").undelegate("click");
// Test this, target and currentTarget are correct
jQuery("#body").delegate('span#liveSpan1', 'click', function(e){
equals( this.id, 'liveSpan1', 'Check the this within a delegate handler' );
equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a delegate handler' );
equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a delegate handler' );
jQuery("#body").delegate("span#liveSpan1", "click", function(e){
equals( this.id, "liveSpan1", "Check the this within a delegate handler" );
equals( e.currentTarget.id, "liveSpan1", "Check the event.currentTarget within a delegate handler" );
equals( e.target.nodeName.toUpperCase(), "A", "Check the event.target within a delegate handler" );
});
jQuery('span#liveSpan1 a').click();
jQuery("span#liveSpan1 a").click();
jQuery("#body").undelegate('span#liveSpan1', 'click');
jQuery("#body").undelegate("span#liveSpan1", "click");
// Work with deep selectors
livee = 0;
@ -2027,11 +2027,11 @@ test("Non DOM element events", function() {
var o = {};
jQuery(o).bind('nonelementobj', function(e) {
jQuery(o).bind("nonelementobj", function(e) {
ok( true, "Event on non-DOM object triggered" );
});
jQuery(o).trigger('nonelementobj');
jQuery(o).trigger("nonelementobj");
});
test("window resize", function() {
@ -2049,7 +2049,7 @@ test("window resize", function() {
test("focusin bubbles", function() {
expect(5);
var input = jQuery( '<input type="text" />' ).prependTo( "body" ),
var input = jQuery( "<input type='text' />" ).prependTo( "body" ),
order = 0;
jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){

View File

@ -9,7 +9,7 @@ var functionReturningObj = function(value) { return (function() { return value;
test("text()", function() {
expect(2);
var expected = "This link has class=\"blog\": Simon Willison's Weblog";
equals( jQuery('#sap').text(), expected, 'Check for merged text of more then one element.' );
equals( jQuery("#sap").text(), expected, "Check for merged text of more then one element." );
// Check serialization of text values
equals( jQuery(document.createTextNode("foo")).text(), "foo", "Text node was retreived from .text()." );
@ -43,34 +43,34 @@ test("text(Function) with incoming value", function() {
var old = "This link has class=\"blog\": Simon Willison's Weblog";
jQuery('#sap').text(function(i, val) {
jQuery("#sap").text(function(i, val) {
equals( val, old, "Make sure the incoming value is correct." );
return "foobar";
});
equals( jQuery("#sap").text(), "foobar", 'Check for merged text of more then one element.' );
equals( jQuery("#sap").text(), "foobar", "Check for merged text of more then one element." );
QUnit.reset();
});
var testWrap = function(val) {
expect(19);
var defaultText = 'Try them out:'
var result = jQuery('#first').wrap(val( '<div class="red"><span></span></div>' )).text();
equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
var defaultText = "Try them out:"
var result = jQuery("#first").wrap(val( "<div class='red'><span></span></div>" )).text();
equals( defaultText, result, "Check for wrapping of on-the-fly html" );
ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
QUnit.reset();
var defaultText = 'Try them out:'
var result = jQuery('#first').wrap(val( document.getElementById('empty') )).parent();
ok( result.is('ol'), 'Check for element wrapping' );
equals( result.text(), defaultText, 'Check for element wrapping' );
var defaultText = "Try them out:"
var result = jQuery("#first").wrap(val( document.getElementById("empty") )).parent();
ok( result.is("ol"), "Check for element wrapping" );
equals( result.text(), defaultText, "Check for element wrapping" );
QUnit.reset();
jQuery('#check1').click(function() {
jQuery("#check1").click(function() {
var checkbox = this;
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
jQuery(checkbox).wrap(val( '<div id="c1" style="display:none;"></div>' ));
jQuery(checkbox).wrap(val( "<div id='c1' style='display:none;'></div>" ));
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
}).click();
@ -143,17 +143,17 @@ var testWrapAll = function(val) {
var prev = jQuery("#firstp")[0].previousSibling;
var p = jQuery("#firstp,#first")[0].parentNode;
var result = jQuery('#firstp,#first').wrapAll(val( '<div class="red"><div class="tmp"></div></div>' ));
equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
ok( jQuery('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
var result = jQuery("#firstp,#first").wrapAll(val( "<div class='red'><div class='tmp'></div></div>" ));
equals( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
ok( jQuery("#firstp").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
equals( jQuery("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );
equals( jQuery("#first").parent().parent()[0].parentNode, p, "Correct Parent" );
QUnit.reset();
var prev = jQuery("#firstp")[0].previousSibling;
var p = jQuery("#first")[0].parentNode;
var result = jQuery('#firstp,#first').wrapAll(val( document.getElementById('empty') ));
var result = jQuery("#firstp,#first").wrapAll(val( document.getElementById("empty") ));
equals( jQuery("#first").parent()[0], jQuery("#firstp").parent()[0], "Same Parent" );
equals( jQuery("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
equals( jQuery("#first").parent()[0].parentNode, p, "Correct Parent" );
@ -166,21 +166,21 @@ test("wrapAll(String|Element)", function() {
var testWrapInner = function(val) {
expect(11);
var num = jQuery("#first").children().length;
var result = jQuery('#first').wrapInner(val('<div class="red"><div id="tmp"></div></div>'));
var result = jQuery("#first").wrapInner(val("<div class='red'><div id='tmp'></div></div>"));
equals( jQuery("#first").children().length, 1, "Only one child" );
ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
equals( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
QUnit.reset();
var num = jQuery("#first").html("foo<div>test</div><div>test2</div>").children().length;
var result = jQuery('#first').wrapInner(val('<div class="red"><div id="tmp"></div></div>'));
var result = jQuery("#first").wrapInner(val("<div class='red'><div id='tmp'></div></div>"));
equals( jQuery("#first").children().length, 1, "Only one child" );
ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
equals( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
QUnit.reset();
var num = jQuery("#first").children().length;
var result = jQuery('#first').wrapInner(val(document.getElementById('empty')));
var result = jQuery("#first").wrapInner(val(document.getElementById("empty")));
equals( jQuery("#first").children().length, 1, "Only one child" );
ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
equals( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
@ -202,51 +202,51 @@ test("wrapInner(Function)", function() {
test("unwrap()", function() {
expect(9);
jQuery("body").append(' <div id="unwrap" style="display: none;"> <div id="unwrap1"> <span class="unwrap">a</span> <span class="unwrap">b</span> </div> <div id="unwrap2"> <span class="unwrap">c</span> <span class="unwrap">d</span> </div> <div id="unwrap3"> <b><span class="unwrap unwrap3">e</span></b> <b><span class="unwrap unwrap3">f</span></b> </div> </div>');
jQuery("body").append(" <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> <div id='unwrap3'> <b><span class='unwrap unwrap3'>e</span></b> <b><span class='unwrap unwrap3'>f</span></b> </div> </div>");
var abcd = jQuery('#unwrap1 > span, #unwrap2 > span').get(),
abcdef = jQuery('#unwrap span').get();
var abcd = jQuery("#unwrap1 > span, #unwrap2 > span").get(),
abcdef = jQuery("#unwrap span").get();
equals( jQuery('#unwrap1 span').add('#unwrap2 span:first').unwrap().length, 3, 'make #unwrap1 and #unwrap2 go away' );
same( jQuery('#unwrap > span').get(), abcd, 'all four spans should still exist' );
equals( jQuery("#unwrap1 span").add("#unwrap2 span:first").unwrap().length, 3, "make #unwrap1 and #unwrap2 go away" );
same( jQuery("#unwrap > span").get(), abcd, "all four spans should still exist" );
same( jQuery('#unwrap3 span').unwrap().get(), jQuery('#unwrap3 > span').get(), 'make all b in #unwrap3 go away' );
same( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap3 > span").get(), "make all b in #unwrap3 go away" );
same( jQuery('#unwrap3 span').unwrap().get(), jQuery('#unwrap > span.unwrap3').get(), 'make #unwrap3 go away' );
same( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap > span.unwrap3").get(), "make #unwrap3 go away" );
same( jQuery('#unwrap').children().get(), abcdef, '#unwrap only contains 6 child spans' );
same( jQuery("#unwrap").children().get(), abcdef, "#unwrap only contains 6 child spans" );
same( jQuery('#unwrap > span').unwrap().get(), jQuery('body > span.unwrap').get(), 'make the 6 spans become children of body' );
same( jQuery("#unwrap > span").unwrap().get(), jQuery("body > span.unwrap").get(), "make the 6 spans become children of body" );
same( jQuery('body > span.unwrap').unwrap().get(), jQuery('body > span.unwrap').get(), 'can\'t unwrap children of body' );
same( jQuery('body > span.unwrap').unwrap().get(), abcdef, 'can\'t unwrap children of body' );
same( jQuery("body > span.unwrap").unwrap().get(), jQuery("body > span.unwrap").get(), "can't unwrap children of body" );
same( jQuery("body > span.unwrap").unwrap().get(), abcdef, "can't unwrap children of body" );
same( jQuery('body > span.unwrap').get(), abcdef, 'body contains 6 .unwrap child spans' );
same( jQuery("body > span.unwrap").get(), abcdef, "body contains 6 .unwrap child spans" );
jQuery('body > span.unwrap').remove();
jQuery("body > span.unwrap").remove();
});
var testAppend = function(valueObj) {
expect(37);
var defaultText = 'Try them out:'
var result = jQuery('#first').append(valueObj('<b>buga</b>'));
equals( result.text(), defaultText + 'buga', 'Check if text appending works' );
equals( jQuery('#select3').append(valueObj('<option value="appendTest">Append Test</option>')).find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
var defaultText = "Try them out:"
var result = jQuery("#first").append(valueObj("<b>buga</b>"));
equals( result.text(), defaultText + "buga", "Check if text appending works" );
equals( jQuery("#select3").append(valueObj("<option value='appendTest'>Append Test</option>")).find("option:last-child").attr("value"), "appendTest", "Appending html options to select element");
QUnit.reset();
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
jQuery('#sap').append(valueObj(document.getElementById('first')));
equals( jQuery('#sap').text(), expected, "Check for appending of element" );
jQuery("#sap").append(valueObj(document.getElementById("first")));
equals( jQuery("#sap").text(), expected, "Check for appending of element" );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
jQuery('#sap').append(valueObj([document.getElementById('first'), document.getElementById('yahoo')]));
equals( jQuery('#sap').text(), expected, "Check for appending of array of elements" );
jQuery("#sap").append(valueObj([document.getElementById("first"), document.getElementById("yahoo")]));
equals( jQuery("#sap").text(), expected, "Check for appending of array of elements" );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
jQuery('#sap').append(valueObj(jQuery("#yahoo, #first")));
equals( jQuery('#sap').text(), expected, "Check for appending of jQuery object" );
jQuery("#sap").append(valueObj(jQuery("#yahoo, #first")));
equals( jQuery("#sap").text(), expected, "Check for appending of jQuery object" );
QUnit.reset();
jQuery("#sap").append(valueObj( 5 ));
@ -262,25 +262,25 @@ var testAppend = function(valueObj) {
ok( jQuery("#sap").append(valueObj( document.getElementsByTagName("foo") )), "Check for appending an empty nodelist." );
QUnit.reset();
jQuery("form").append(valueObj('<input name="radiotest" type="radio" checked="checked" />'));
jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked='checked' />"));
jQuery("form input[name=radiotest]").each(function(){
ok( jQuery(this).is(':checked'), "Append checked radio");
ok( jQuery(this).is(":checked"), "Append checked radio");
}).remove();
QUnit.reset();
jQuery("form").append(valueObj('<input name="radiotest" type="radio" checked = \'checked\' />'));
jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked = 'checked' />"));
jQuery("form input[name=radiotest]").each(function(){
ok( jQuery(this).is(':checked'), "Append alternately formated checked radio");
ok( jQuery(this).is(":checked"), "Append alternately formated checked radio");
}).remove();
QUnit.reset();
jQuery("form").append(valueObj('<input name="radiotest" type="radio" checked />'));
jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked />"));
jQuery("form input[name=radiotest]").each(function(){
ok( jQuery(this).is(':checked'), "Append HTML5-formated checked radio");
ok( jQuery(this).is(":checked"), "Append HTML5-formated checked radio");
}).remove();
QUnit.reset();
jQuery("#sap").append(valueObj( document.getElementById('form') ));
jQuery("#sap").append(valueObj( document.getElementById("form") ));
equals( jQuery("#sap>form").size(), 1, "Check for appending a form" ); // Bug #910
QUnit.reset();
@ -296,31 +296,31 @@ var testAppend = function(valueObj) {
ok( pass, "Test for appending a DOM node to the contents of an IFrame" );
QUnit.reset();
jQuery('<fieldset/>').appendTo('#form').append(valueObj( '<legend id="legend">test</legend>' ));
t( 'Append legend', '#legend', ['legend'] );
jQuery("<fieldset/>").appendTo("#form").append(valueObj( "<legend id='legend'>test</legend>" ));
t( "Append legend", "#legend", ["legend"] );
QUnit.reset();
jQuery('#select1').append(valueObj( '<OPTION>Test</OPTION>' ));
equals( jQuery('#select1 option:last').text(), "Test", "Appending &lt;OPTION&gt; (all caps)" );
jQuery("#select1").append(valueObj( "<OPTION>Test</OPTION>" ));
equals( jQuery("#select1 option:last").text(), "Test", "Appending &lt;OPTION&gt; (all caps)" );
jQuery('#table').append(valueObj( '<colgroup></colgroup>' ));
ok( jQuery('#table colgroup').length, "Append colgroup" );
jQuery("#table").append(valueObj( "<colgroup></colgroup>" ));
ok( jQuery("#table colgroup").length, "Append colgroup" );
jQuery('#table colgroup').append(valueObj( '<col/>' ));
ok( jQuery('#table colgroup col').length, "Append col" );
jQuery("#table colgroup").append(valueObj( "<col/>" ));
ok( jQuery("#table colgroup col").length, "Append col" );
QUnit.reset();
jQuery('#table').append(valueObj( '<caption></caption>' ));
ok( jQuery('#table caption').length, "Append caption" );
jQuery("#table").append(valueObj( "<caption></caption>" ));
ok( jQuery("#table caption").length, "Append caption" );
QUnit.reset();
jQuery('form:last')
.append(valueObj( '<select id="appendSelect1"></select>' ))
.append(valueObj( '<select id="appendSelect2"><option>Test</option></select>' ));
jQuery("form:last")
.append(valueObj( "<select id='appendSelect1'></select>" ))
.append(valueObj( "<select id='appendSelect2'><option>Test</option></select>" ));
t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
equals( "Two nodes", jQuery('<div />').append("Two", " nodes").text(), "Appending two text nodes (#4011)" );
equals( "Two nodes", jQuery("<div />").append("Two", " nodes").text(), "Appending two text nodes (#4011)" );
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
@ -343,51 +343,51 @@ test("append(Function)", function() {
test("append(Function) with incoming value", function() {
expect(12);
var defaultText = 'Try them out:', old = jQuery("#first").html();
var defaultText = "Try them out:", old = jQuery("#first").html();
var result = jQuery('#first').append(function(i, val){
var result = jQuery("#first").append(function(i, val){
equals( val, old, "Make sure the incoming value is correct." );
return '<b>buga</b>';
return "<b>buga</b>";
});
equals( result.text(), defaultText + 'buga', 'Check if text appending works' );
equals( result.text(), defaultText + "buga", "Check if text appending works" );
var select = jQuery('#select3');
var select = jQuery("#select3");
old = select.html();
equals( select.append(function(i, val){
equals( val, old, "Make sure the incoming value is correct." );
return '<option value="appendTest">Append Test</option>';
}).find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
return "<option value='appendTest'>Append Test</option>";
}).find("option:last-child").attr("value"), "appendTest", "Appending html options to select element");
QUnit.reset();
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
old = jQuery("#sap").html();
jQuery('#sap').append(function(i, val){
jQuery("#sap").append(function(i, val){
equals( val, old, "Make sure the incoming value is correct." );
return document.getElementById('first');
return document.getElementById("first");
});
equals( jQuery('#sap').text(), expected, "Check for appending of element" );
equals( jQuery("#sap").text(), expected, "Check for appending of element" );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
old = jQuery("#sap").html();
jQuery('#sap').append(function(i, val){
jQuery("#sap").append(function(i, val){
equals( val, old, "Make sure the incoming value is correct." );
return [document.getElementById('first'), document.getElementById('yahoo')];
return [document.getElementById("first"), document.getElementById("yahoo")];
});
equals( jQuery('#sap').text(), expected, "Check for appending of array of elements" );
equals( jQuery("#sap").text(), expected, "Check for appending of array of elements" );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
old = jQuery("#sap").html();
jQuery('#sap').append(function(i, val){
jQuery("#sap").append(function(i, val){
equals( val, old, "Make sure the incoming value is correct." );
return jQuery("#yahoo, #first");
});
equals( jQuery('#sap').text(), expected, "Check for appending of jQuery object" );
equals( jQuery("#sap").text(), expected, "Check for appending of jQuery object" );
QUnit.reset();
old = jQuery("#sap").html();
@ -414,11 +414,11 @@ test("append the same fragment with events (Bug #6997, 5566)", function () {
if ( doExtra ) {
element = jQuery("div:first").click(function () {
ok(true, "Event exists on original after being unbound on clone");
jQuery(this).unbind('click');
jQuery(this).unbind("click");
});
var clone = element.clone(true).unbind('click');
clone[0].fireEvent('onclick');
element[0].fireEvent('onclick');
var clone = element.clone(true).unbind("click");
clone[0].fireEvent("onclick");
element[0].fireEvent("onclick");
// manually clean up detached elements
clone.remove();
@ -429,7 +429,7 @@ test("append the same fragment with events (Bug #6997, 5566)", function () {
});
jQuery("#listWithTabIndex li").append(element)
.find('a.test6997').eq(1).click();
.find("a.test6997").eq(1).click();
element = jQuery("<li class='test6997'></li>").click(function () {
ok(true, "Before second element events work");
@ -443,10 +443,10 @@ test("append the same fragment with events (Bug #6997, 5566)", function () {
test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
expect(16);
var defaultText = 'Try them out:'
jQuery('<b>buga</b>').appendTo('#first');
equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' );
equals( jQuery('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
var defaultText = "Try them out:"
jQuery("<b>buga</b>").appendTo("#first");
equals( jQuery("#first").text(), defaultText + "buga", "Check if text appending works" );
equals( jQuery("<option value='appendTest'>Append Test</option>").appendTo("#select3").parent().find("option:last-child").attr("value"), "appendTest", "Appending html options to select element");
QUnit.reset();
var l = jQuery("#first").children().length + 2;
@ -459,25 +459,25 @@ test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
QUnit.reset();
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
jQuery(document.getElementById('first')).appendTo('#sap');
equals( jQuery('#sap').text(), expected, "Check for appending of element" );
jQuery(document.getElementById("first")).appendTo("#sap");
equals( jQuery("#sap").text(), expected, "Check for appending of element" );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
jQuery([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
equals( jQuery('#sap').text(), expected, "Check for appending of array of elements" );
jQuery([document.getElementById("first"), document.getElementById("yahoo")]).appendTo("#sap");
equals( jQuery("#sap").text(), expected, "Check for appending of array of elements" );
QUnit.reset();
ok( jQuery(document.createElement("script")).appendTo("body").length, "Make sure a disconnected script can be appended." );
QUnit.reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
jQuery("#yahoo, #first").appendTo('#sap');
equals( jQuery('#sap').text(), expected, "Check for appending of jQuery object" );
jQuery("#yahoo, #first").appendTo("#sap");
equals( jQuery("#sap").text(), expected, "Check for appending of jQuery object" );
QUnit.reset();
jQuery('#select1').appendTo('#foo');
t( 'Append select', '#foo select', ['select1'] );
jQuery("#select1").appendTo("#foo");
t( "Append select", "#foo select", ["select1"] );
QUnit.reset();
var div = jQuery("<div/>").click(function(){
@ -517,25 +517,25 @@ test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
var testPrepend = function(val) {
expect(5);
var defaultText = 'Try them out:'
var result = jQuery('#first').prepend(val( '<b>buga</b>' ));
equals( result.text(), 'buga' + defaultText, 'Check if text prepending works' );
equals( jQuery('#select3').prepend(val( '<option value="prependTest">Prepend Test</option>' )).find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
var defaultText = "Try them out:"
var result = jQuery("#first").prepend(val( "<b>buga</b>" ));
equals( result.text(), "buga" + defaultText, "Check if text prepending works" );
equals( jQuery("#select3").prepend(val( "<option value='prependTest'>Prepend Test</option>" )).find("option:first-child").attr("value"), "prependTest", "Prepending html options to select element");
QUnit.reset();
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
jQuery('#sap').prepend(val( document.getElementById('first') ));
equals( jQuery('#sap').text(), expected, "Check for prepending of element" );
jQuery("#sap").prepend(val( document.getElementById("first") ));
equals( jQuery("#sap").text(), expected, "Check for prepending of element" );
QUnit.reset();
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
jQuery('#sap').prepend(val( [document.getElementById('first'), document.getElementById('yahoo')] ));
equals( jQuery('#sap').text(), expected, "Check for prepending of array of elements" );
jQuery("#sap").prepend(val( [document.getElementById("first"), document.getElementById("yahoo")] ));
equals( jQuery("#sap").text(), expected, "Check for prepending of array of elements" );
QUnit.reset();
expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
jQuery('#sap').prepend(val( jQuery("#yahoo, #first") ));
equals( jQuery('#sap').text(), expected, "Check for prepending of jQuery object" );
jQuery("#sap").prepend(val( jQuery("#yahoo, #first") ));
equals( jQuery("#sap").text(), expected, "Check for prepending of jQuery object" );
};
test("prepend(String|Element|Array&lt;Element&gt;|jQuery)", function() {
@ -549,103 +549,103 @@ test("prepend(Function)", function() {
test("prepend(Function) with incoming value", function() {
expect(10);
var defaultText = 'Try them out:', old = jQuery('#first').html();
var result = jQuery('#first').prepend(function(i, val) {
var defaultText = "Try them out:", old = jQuery("#first").html();
var result = jQuery("#first").prepend(function(i, val) {
equals( val, old, "Make sure the incoming value is correct." );
return '<b>buga</b>';
return "<b>buga</b>";
});
equals( result.text(), 'buga' + defaultText, 'Check if text prepending works' );
equals( result.text(), "buga" + defaultText, "Check if text prepending works" );
old = jQuery("#select3").html();
equals( jQuery('#select3').prepend(function(i, val) {
equals( jQuery("#select3").prepend(function(i, val) {
equals( val, old, "Make sure the incoming value is correct." );
return '<option value="prependTest">Prepend Test</option>';
}).find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
return "<option value='prependTest'>Prepend Test</option>";
}).find("option:first-child").attr("value"), "prependTest", "Prepending html options to select element");
QUnit.reset();
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
old = jQuery('#sap').html();
old = jQuery("#sap").html();
jQuery('#sap').prepend(function(i, val) {
jQuery("#sap").prepend(function(i, val) {
equals( val, old, "Make sure the incoming value is correct." );
return document.getElementById('first');
return document.getElementById("first");
});
equals( jQuery('#sap').text(), expected, "Check for prepending of element" );
equals( jQuery("#sap").text(), expected, "Check for prepending of element" );
QUnit.reset();
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
old = jQuery('#sap').html();
old = jQuery("#sap").html();
jQuery('#sap').prepend(function(i, val) {
jQuery("#sap").prepend(function(i, val) {
equals( val, old, "Make sure the incoming value is correct." );
return [document.getElementById('first'), document.getElementById('yahoo')];
return [document.getElementById("first"), document.getElementById("yahoo")];
});
equals( jQuery('#sap').text(), expected, "Check for prepending of array of elements" );
equals( jQuery("#sap").text(), expected, "Check for prepending of array of elements" );
QUnit.reset();
expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
old = jQuery('#sap').html();
old = jQuery("#sap").html();
jQuery('#sap').prepend(function(i, val) {
jQuery("#sap").prepend(function(i, val) {
equals( val, old, "Make sure the incoming value is correct." );
return jQuery("#yahoo, #first");
});
equals( jQuery('#sap').text(), expected, "Check for prepending of jQuery object" );
equals( jQuery("#sap").text(), expected, "Check for prepending of jQuery object" );
});
test("prependTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
expect(6);
var defaultText = 'Try them out:'
jQuery('<b>buga</b>').prependTo('#first');
equals( jQuery('#first').text(), 'buga' + defaultText, 'Check if text prepending works' );
equals( jQuery('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
var defaultText = "Try them out:"
jQuery("<b>buga</b>").prependTo("#first");
equals( jQuery("#first").text(), "buga" + defaultText, "Check if text prepending works" );
equals( jQuery("<option value='prependTest'>Prepend Test</option>").prependTo("#select3").parent().find("option:first-child").attr("value"), "prependTest", "Prepending html options to select element");
QUnit.reset();
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
jQuery(document.getElementById('first')).prependTo('#sap');
equals( jQuery('#sap').text(), expected, "Check for prepending of element" );
jQuery(document.getElementById("first")).prependTo("#sap");
equals( jQuery("#sap").text(), expected, "Check for prepending of element" );
QUnit.reset();
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
jQuery([document.getElementById('first'), document.getElementById('yahoo')]).prependTo('#sap');
equals( jQuery('#sap').text(), expected, "Check for prepending of array of elements" );
jQuery([document.getElementById("first"), document.getElementById("yahoo")]).prependTo("#sap");
equals( jQuery("#sap").text(), expected, "Check for prepending of array of elements" );
QUnit.reset();
expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
jQuery("#yahoo, #first").prependTo('#sap');
equals( jQuery('#sap').text(), expected, "Check for prepending of jQuery object" );
jQuery("#yahoo, #first").prependTo("#sap");
equals( jQuery("#sap").text(), expected, "Check for prepending of jQuery object" );
QUnit.reset();
jQuery('<select id="prependSelect1"></select>').prependTo('form:last');
jQuery('<select id="prependSelect2"><option>Test</option></select>').prependTo('form:last');
jQuery("<select id='prependSelect1'></select>").prependTo("form:last");
jQuery("<select id='prependSelect2'><option>Test</option></select>").prependTo("form:last");
t( "Prepend Select", "#prependSelect2, #prependSelect1", ["prependSelect2", "prependSelect1"] );
});
var testBefore = function(val) {
expect(6);
var expected = 'This is a normal link: bugaYahoo';
jQuery('#yahoo').before(val( '<b>buga</b>' ));
equals( jQuery('#en').text(), expected, 'Insert String before' );
var expected = "This is a normal link: bugaYahoo";
jQuery("#yahoo").before(val( "<b>buga</b>" ));
equals( jQuery("#en").text(), expected, "Insert String before" );
QUnit.reset();
expected = "This is a normal link: Try them out:Yahoo";
jQuery('#yahoo').before(val( document.getElementById('first') ));
equals( jQuery('#en').text(), expected, "Insert element before" );
jQuery("#yahoo").before(val( document.getElementById("first") ));
equals( jQuery("#en").text(), expected, "Insert element before" );
QUnit.reset();
expected = "This is a normal link: Try them out:diveintomarkYahoo";
jQuery('#yahoo').before(val( [document.getElementById('first'), document.getElementById('mark')] ));
equals( jQuery('#en').text(), expected, "Insert array of elements before" );
jQuery("#yahoo").before(val( [document.getElementById("first"), document.getElementById("mark")] ));
equals( jQuery("#en").text(), expected, "Insert array of elements before" );
QUnit.reset();
expected = "This is a normal link: diveintomarkTry them out:Yahoo";
jQuery('#yahoo').before(val( jQuery("#mark, #first") ));
equals( jQuery('#en').text(), expected, "Insert jQuery before" );
jQuery("#yahoo").before(val( jQuery("#mark, #first") ));
equals( jQuery("#en").text(), expected, "Insert jQuery before" );
var set = jQuery("<div/>").before("<span>test</span>");
equals( set[0].nodeName.toLowerCase(), "span", "Insert the element before the disconnected node." );
@ -662,46 +662,46 @@ test("before(Function)", function() {
test("insertBefore(String|Element|Array&lt;Element&gt;|jQuery)", function() {
expect(4);
var expected = 'This is a normal link: bugaYahoo';
jQuery('<b>buga</b>').insertBefore('#yahoo');
equals( jQuery('#en').text(), expected, 'Insert String before' );
var expected = "This is a normal link: bugaYahoo";
jQuery("<b>buga</b>").insertBefore("#yahoo");
equals( jQuery("#en").text(), expected, "Insert String before" );
QUnit.reset();
expected = "This is a normal link: Try them out:Yahoo";
jQuery(document.getElementById('first')).insertBefore('#yahoo');
equals( jQuery('#en').text(), expected, "Insert element before" );
jQuery(document.getElementById("first")).insertBefore("#yahoo");
equals( jQuery("#en").text(), expected, "Insert element before" );
QUnit.reset();
expected = "This is a normal link: Try them out:diveintomarkYahoo";
jQuery([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');
equals( jQuery('#en').text(), expected, "Insert array of elements before" );
jQuery([document.getElementById("first"), document.getElementById("mark")]).insertBefore("#yahoo");
equals( jQuery("#en").text(), expected, "Insert array of elements before" );
QUnit.reset();
expected = "This is a normal link: diveintomarkTry them out:Yahoo";
jQuery("#mark, #first").insertBefore('#yahoo');
equals( jQuery('#en').text(), expected, "Insert jQuery before" );
jQuery("#mark, #first").insertBefore("#yahoo");
equals( jQuery("#en").text(), expected, "Insert jQuery before" );
});
var testAfter = function(val) {
expect(6);
var expected = 'This is a normal link: Yahoobuga';
jQuery('#yahoo').after(val( '<b>buga</b>' ));
equals( jQuery('#en').text(), expected, 'Insert String after' );
var expected = "This is a normal link: Yahoobuga";
jQuery("#yahoo").after(val( "<b>buga</b>" ));
equals( jQuery("#en").text(), expected, "Insert String after" );
QUnit.reset();
expected = "This is a normal link: YahooTry them out:";
jQuery('#yahoo').after(val( document.getElementById('first') ));
equals( jQuery('#en').text(), expected, "Insert element after" );
jQuery("#yahoo").after(val( document.getElementById("first") ));
equals( jQuery("#en").text(), expected, "Insert element after" );
QUnit.reset();
expected = "This is a normal link: YahooTry them out:diveintomark";
jQuery('#yahoo').after(val( [document.getElementById('first'), document.getElementById('mark')] ));
equals( jQuery('#en').text(), expected, "Insert array of elements after" );
jQuery("#yahoo").after(val( [document.getElementById("first"), document.getElementById("mark")] ));
equals( jQuery("#en").text(), expected, "Insert array of elements after" );
QUnit.reset();
expected = "This is a normal link: YahoodiveintomarkTry them out:";
jQuery('#yahoo').after(val( jQuery("#mark, #first") ));
equals( jQuery('#en').text(), expected, "Insert jQuery after" );
jQuery("#yahoo").after(val( jQuery("#mark, #first") ));
equals( jQuery("#en").text(), expected, "Insert jQuery after" );
var set = jQuery("<div/>").after("<span>test</span>");
equals( set[1].nodeName.toLowerCase(), "span", "Insert the element after the disconnected node." );
@ -718,58 +718,58 @@ test("after(Function)", function() {
test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() {
expect(4);
var expected = 'This is a normal link: Yahoobuga';
jQuery('<b>buga</b>').insertAfter('#yahoo');
equals( jQuery('#en').text(), expected, 'Insert String after' );
var expected = "This is a normal link: Yahoobuga";
jQuery("<b>buga</b>").insertAfter("#yahoo");
equals( jQuery("#en").text(), expected, "Insert String after" );
QUnit.reset();
expected = "This is a normal link: YahooTry them out:";
jQuery(document.getElementById('first')).insertAfter('#yahoo');
equals( jQuery('#en').text(), expected, "Insert element after" );
jQuery(document.getElementById("first")).insertAfter("#yahoo");
equals( jQuery("#en").text(), expected, "Insert element after" );
QUnit.reset();
expected = "This is a normal link: YahooTry them out:diveintomark";
jQuery([document.getElementById('first'), document.getElementById('mark')]).insertAfter('#yahoo');
equals( jQuery('#en').text(), expected, "Insert array of elements after" );
jQuery([document.getElementById("first"), document.getElementById("mark")]).insertAfter("#yahoo");
equals( jQuery("#en").text(), expected, "Insert array of elements after" );
QUnit.reset();
expected = "This is a normal link: YahoodiveintomarkTry them out:";
jQuery("#mark, #first").insertAfter('#yahoo');
equals( jQuery('#en').text(), expected, "Insert jQuery after" );
jQuery("#mark, #first").insertAfter("#yahoo");
equals( jQuery("#en").text(), expected, "Insert jQuery after" );
});
var testReplaceWith = function(val) {
expect(21);
jQuery('#yahoo').replaceWith(val( '<b id="replace">buga</b>' ));
ok( jQuery("#replace")[0], 'Replace element with string' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
jQuery("#yahoo").replaceWith(val( "<b id='replace'>buga</b>" ));
ok( jQuery("#replace")[0], "Replace element with string" );
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after string" );
QUnit.reset();
jQuery('#yahoo').replaceWith(val( document.getElementById('first') ));
ok( jQuery("#first")[0], 'Replace element with element' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
jQuery("#yahoo").replaceWith(val( document.getElementById("first") ));
ok( jQuery("#first")[0], "Replace element with element" );
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after element" );
QUnit.reset();
jQuery("#main").append('<div id="bar"><div id="baz">Foo</div></div>');
jQuery('#baz').replaceWith("Baz");
equals( jQuery("#bar").text(),"Baz", 'Replace element with text' );
ok( !jQuery("#baz")[0], 'Verify that original element is gone, after element' );
jQuery("#main").append("<div id='bar'><div id='baz'</div></div>");
jQuery("#baz").replaceWith("Baz");
equals( jQuery("#bar").text(),"Baz", "Replace element with text" );
ok( !jQuery("#baz")[0], "Verify that original element is gone, after element" );
QUnit.reset();
jQuery('#yahoo').replaceWith(val( [document.getElementById('first'), document.getElementById('mark')] ));
ok( jQuery("#first")[0], 'Replace element with array of elements' );
ok( jQuery("#mark")[0], 'Replace element with array of elements' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
jQuery("#yahoo").replaceWith(val( [document.getElementById("first"), document.getElementById("mark")] ));
ok( jQuery("#first")[0], "Replace element with array of elements" );
ok( jQuery("#mark")[0], "Replace element with array of elements" );
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after array of elements" );
QUnit.reset();
jQuery('#yahoo').replaceWith(val( jQuery("#mark, #first") ));
ok( jQuery("#first")[0], 'Replace element with set of elements' );
ok( jQuery("#mark")[0], 'Replace element with set of elements' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
jQuery("#yahoo").replaceWith(val( jQuery("#mark, #first") ));
ok( jQuery("#first")[0], "Replace element with set of elements" );
ok( jQuery("#mark")[0], "Replace element with set of elements" );
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after set of elements" );
QUnit.reset();
var tmp = jQuery("<div/>").appendTo("body").click(function(){ ok(true, "Newly bound click run." ); });
var y = jQuery('<div/>').appendTo("body").click(function(){ ok(true, "Previously bound click run." ); });
var y = jQuery("<div/>").appendTo("body").click(function(){ ok(true, "Previously bound click run." ); });
var child = y.append("<b>test</b>").find("b").click(function(){ ok(true, "Child bound click run." ); return false; });
y.replaceWith( tmp );
@ -784,7 +784,7 @@ var testReplaceWith = function(val) {
QUnit.reset();
y = jQuery('<div/>').appendTo("body").click(function(){ ok(true, "Previously bound click run." ); });
y = jQuery("<div/>").appendTo("body").click(function(){ ok(true, "Previously bound click run." ); });
var child2 = y.append("<u>test</u>").find("u").click(function(){ ok(true, "Child 2 bound click run." ); return false; });
y.replaceWith( child2 );
@ -800,7 +800,7 @@ var testReplaceWith = function(val) {
equals( set[0].nodeName.toLowerCase(), "span", "Replace the disconnected node." );
equals( set.length, 1, "Replace the disconnected node." );
var non_existant = jQuery('#does-not-exist').replaceWith( val("<b>should not throw an error</b>") );
var non_existant = jQuery("#does-not-exist").replaceWith( val("<b>should not throw an error</b>") );
equals( non_existant.length, 0, "Length of non existant element." );
var $div = jQuery("<div class='replacewith'></div>").appendTo("body");
@ -808,8 +808,8 @@ var testReplaceWith = function(val) {
//$div.replaceWith("<div class='replacewith'></div><script>" +
//"equals(jQuery('.replacewith').length, 1, 'Check number of elements in page.');" +
//"</script>");
equals(jQuery('.replacewith').length, 1, 'Check number of elements in page.');
jQuery('.replacewith').remove();
equals(jQuery(".replacewith").length, 1, "Check number of elements in page.");
jQuery(".replacewith").remove();
QUnit.reset();
@ -844,35 +844,35 @@ test("replaceWith(Function)", function() {
test("replaceWith(string) for more than one element", function(){
expect(3);
equals(jQuery('#foo p').length, 3, 'ensuring that test data has not changed');
equals(jQuery("#foo p").length, 3, "ensuring that test data has not changed");
jQuery('#foo p').replaceWith('<span>bar</span>');
equals(jQuery('#foo span').length, 3, 'verify that all the three original element have been replaced');
equals(jQuery('#foo p').length, 0, 'verify that all the three original element have been replaced');
jQuery("#foo p").replaceWith("<span>bar</span>");
equals(jQuery("#foo span").length, 3, "verify that all the three original element have been replaced");
equals(jQuery("#foo p").length, 0, "verify that all the three original element have been replaced");
});
test("replaceAll(String|Element|Array&lt;Element&gt;|jQuery)", function() {
expect(10);
jQuery('<b id="replace">buga</b>').replaceAll("#yahoo");
ok( jQuery("#replace")[0], 'Replace element with string' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
jQuery("<b id='replace'>buga</b>").replaceAll("#yahoo");
ok( jQuery("#replace")[0], "Replace element with string" );
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after string" );
QUnit.reset();
jQuery(document.getElementById('first')).replaceAll("#yahoo");
ok( jQuery("#first")[0], 'Replace element with element' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
jQuery(document.getElementById("first")).replaceAll("#yahoo");
ok( jQuery("#first")[0], "Replace element with element" );
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after element" );
QUnit.reset();
jQuery([document.getElementById('first'), document.getElementById('mark')]).replaceAll("#yahoo");
ok( jQuery("#first")[0], 'Replace element with array of elements' );
ok( jQuery("#mark")[0], 'Replace element with array of elements' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
jQuery([document.getElementById("first"), document.getElementById("mark")]).replaceAll("#yahoo");
ok( jQuery("#first")[0], "Replace element with array of elements" );
ok( jQuery("#mark")[0], "Replace element with array of elements" );
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after array of elements" );
QUnit.reset();
jQuery("#mark, #first").replaceAll("#yahoo");
ok( jQuery("#first")[0], 'Replace element with set of elements' );
ok( jQuery("#mark")[0], 'Replace element with set of elements' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
ok( jQuery("#first")[0], "Replace element with set of elements" );
ok( jQuery("#mark")[0], "Replace element with set of elements" );
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after set of elements" );
});
test("jQuery.clone() (#8017)", function() {
@ -890,9 +890,9 @@ test("jQuery.clone() (#8017)", function() {
test("clone() (#8070)", function () {
expect(2);
jQuery('<select class="test8070"></select><select class="test8070"></select>').appendTo('#main');
var selects = jQuery('.test8070');
selects.append('<OPTION>1</OPTION><OPTION>2</OPTION>');
jQuery("<select class='test8070'></select><select class='test8070'></select>").appendTo("#main");
var selects = jQuery(".test8070");
selects.append("<OPTION>1</OPTION><OPTION>2</OPTION>");
equals( selects[0].childNodes.length, 2, "First select got two nodes" );
equals( selects[1].childNodes.length, 2, "Second select got two nodes" );
@ -902,10 +902,10 @@ test("clone() (#8070)", function () {
test("clone()", function() {
expect(37);
equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' );
var clone = jQuery('#yahoo').clone();
equals( 'Try them out:Yahoo', jQuery('#first').append(clone).text(), 'Check for clone' );
equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Reassert text for #en' );
equals( "This is a normal link: Yahoo", jQuery("#en").text(), "Assert text for #en" );
var clone = jQuery("#yahoo").clone();
equals( "Try them out:Yahoo", jQuery("#first").append(clone).text(), "Check for clone" );
equals( "This is a normal link: Yahoo", jQuery("#en").text(), "Reassert text for #en" );
var cloneTags = [
"<table/>", "<tr/>", "<td/>", "<div/>",
@ -915,7 +915,7 @@ test("clone()", function() {
];
for (var i = 0; i < cloneTags.length; i++) {
var j = jQuery(cloneTags[i]);
equals( j[0].tagName, j.clone()[0].tagName, 'Clone a ' + cloneTags[i]);
equals( j[0].tagName, j.clone()[0].tagName, "Clone a " + cloneTags[i]);
}
// using contents will get comments regular, text, and comment nodes
@ -971,7 +971,7 @@ test("clone()", function() {
// this is technically an invalid object, but because of the special
// classid instantiation it is the only kind that IE has trouble with,
// so let's test with it too.
div = jQuery("<div/>").html('<object height="355" width="425" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="movie" value="http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en"> <param name="wmode" value="transparent"> </object>');
div = jQuery("<div/>").html("<object height='355' width='425' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'> <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'> <param name='wmode' value='transparent'> </object>");
clone = div.clone(true);
equals( clone.length, 1, "One element cloned" );
@ -979,7 +979,7 @@ test("clone()", function() {
equals( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
// and here's a valid one.
div = jQuery("<div/>").html('<object height="355" width="425" type="application/x-shockwave-flash" data="http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en"> <param name="movie" value="http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en"> <param name="wmode" value="transparent"> </object>');
div = jQuery("<div/>").html("<object height='355' width='425' type='application/x-shockwave-flash' data='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'> <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'> <param name='wmode' value='transparent'> </object>");
clone = div.clone(true);
equals( clone.length, 1, "One element cloned" );
@ -1014,7 +1014,7 @@ test("clone(form element) (Bug #3879, #6655)", function() {
equals( element.clone().find("option:selected").val(), element.find("option:selected").val(), "Selected option cloned correctly" );
element = jQuery("<input type='checkbox' value='foo'>").attr('checked', 'checked');
element = jQuery("<input type='checkbox' value='foo'>").attr("checked", "checked");
clone = element.clone();
equals( clone.is(":checked"), element.is(":checked"), "Checked input cloned correctly" );
@ -1070,7 +1070,7 @@ var testHtml = function(valueObj) {
}
ok( pass, "Set HTML" );
div = jQuery("<div/>").html( valueObj('<div id="parent_1"><div id="child_1"/></div><div id="parent_2"/>') );
div = jQuery("<div/>").html( valueObj("<div id='parent_1'><div id='child_1'/></div><div id='parent_2'/>") );
equals( div.children().length, 2, "Make sure two child nodes exist." );
equals( div.children().children().length, 1, "Make sure that a grandchild exists." );
@ -1090,18 +1090,18 @@ var testHtml = function(valueObj) {
j.html(valueObj("<b>bold</b>"));
// this is needed, or the expando added by jQuery unique will yield a different html
j.find('b').removeData();
j.find("b").removeData();
equals( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );
jQuery("#main").html(valueObj("<select/>"));
jQuery("#main select").html(valueObj("<option>O1</option><option selected='selected'>O2</option><option>O3</option>"));
equals( jQuery("#main select").val(), "O2", "Selected option correct" );
var $div = jQuery('<div />');
equals( $div.html(valueObj( 5 )).html(), '5', 'Setting a number as html' );
equals( $div.html(valueObj( 0 )).html(), '0', 'Setting a zero as html' );
var $div = jQuery("<div />");
equals( $div.html(valueObj( 5 )).html(), "5", "Setting a number as html" );
equals( $div.html(valueObj( 0 )).html(), "0", "Setting a zero as html" );
var $div2 = jQuery('<div/>'), insert = "&lt;div&gt;hello1&lt;/div&gt;";
var $div2 = jQuery("<div/>"), insert = "&lt;div&gt;hello1&lt;/div&gt;";
equals( $div2.html(insert).html().replace(/>/g, "&gt;"), insert, "Verify escaped insertion." );
equals( $div2.html("x" + insert).html().replace(/>/g, "&gt;"), "x" + insert, "Verify escaped insertion." );
equals( $div2.html(" " + insert).html().replace(/>/g, "&gt;"), " " + insert, "Verify escaped insertion." );
@ -1113,15 +1113,15 @@ var testHtml = function(valueObj) {
QUnit.reset();
jQuery("#main").html(valueObj('<script type="something/else">ok( false, "Non-script evaluated." );</script><script type="text/javascript">ok( true, "text/javascript is evaluated." );</script><script>ok( true, "No type is evaluated." );</script><div><script type="text/javascript">ok( true, "Inner text/javascript is evaluated." );</script><script>ok( true, "Inner No type is evaluated." );</script><script type="something/else">ok( false, "Non-script evaluated." );</script></div>'));
jQuery("#main").html(valueObj("<script type='something/else'>ok( false, 'Non-script evaluated.' );</script><script type='text/javascript'>ok( true, 'text/javascript is evaluated.' );</script><script>ok( true, 'No type is evaluated.' );</script><div><script type='text/javascript'>ok( true, 'Inner text/javascript is evaluated.' );</script><script>ok( true, 'Inner No type is evaluated.' );</script><script type='something/else'>ok( false, 'Non-script evaluated.' );</script></div>"));
jQuery("#main").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
jQuery("#main").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
jQuery("#main").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
jQuery("#main").html(valueObj('<script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (1)" );</script>'));
jQuery("#main").html(valueObj("<script type='text/javascript'>ok( true, 'jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (1)' );</script>"));
jQuery("#main").html(valueObj('foo <form><script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (2)" );</script></form>'));
jQuery("#main").html(valueObj("foo <form><script type='text/javascript'>ok( true, 'jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (2)' );</script></form>"));
jQuery("#main").html(valueObj("<script>equals(jQuery.scriptorder++, 0, 'Script is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>equals(jQuery.scriptorder++, 1, 'Script (nested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script></span><script>equals(jQuery.scriptorder++, 2, 'Script (unnested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script>"));
}
@ -1178,22 +1178,22 @@ test("html(Function) with incoming value", function() {
equals( null, null, "Make sure the incoming value is correct." );
}
j.find('b').removeData();
j.find("b").removeData();
equals( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );
var $div = jQuery('<div />');
var $div = jQuery("<div />");
equals( $div.html(function(i, val) {
equals( val, "", "Make sure the incoming value is correct." );
return 5;
}).html(), '5', 'Setting a number as html' );
}).html(), "5", "Setting a number as html" );
equals( $div.html(function(i, val) {
equals( val, "5", "Make sure the incoming value is correct." );
return 0;
}).html(), '0', 'Setting a zero as html' );
}).html(), "0", "Setting a zero as html" );
var $div2 = jQuery('<div/>'), insert = "&lt;div&gt;hello1&lt;/div&gt;";
var $div2 = jQuery("<div/>"), insert = "&lt;div&gt;hello1&lt;/div&gt;";
equals( $div2.html(function(i, val) {
equals( val, "", "Make sure the incoming value is correct." );
return insert;
@ -1362,6 +1362,6 @@ test("jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
}
catch(e) {}
}
equals($f.text(), bad.join(''), "Cached strings that match Object properties");
equals($f.text(), bad.join(""), "Cached strings that match Object properties");
$f.remove();
});

View File

@ -20,7 +20,7 @@ testoffset("absolute"/* in iframe */, function($, iframe) {
// this insures that the results will be wrong
// if the offset method is using the scroll offset
// of the parent window
var forceScroll = jQuery('<div>', { width: 2000, height: 2000 }).appendTo('body');
var forceScroll = jQuery("<div>", { width: 2000, height: 2000 }).appendTo("body");
window.scrollTo(200, 200);
if ( document.documentElement.scrollTop || document.body.scrollTop ) {
@ -31,7 +31,7 @@ testoffset("absolute"/* in iframe */, function($, iframe) {
// get offset
tests = [
{ id: '#absolute-1', top: 1, left: 1 }
{ id: "#absolute-1", top: 1, left: 1 }
];
jQuery.each( tests, function() {
equals( jQuery( this.id, doc ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
@ -41,7 +41,7 @@ testoffset("absolute"/* in iframe */, function($, iframe) {
// get position
tests = [
{ id: '#absolute-1', top: 0, left: 0 }
{ id: "#absolute-1", top: 0, left: 0 }
];
jQuery.each( tests, function() {
equals( jQuery( this.id, doc ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
@ -56,10 +56,10 @@ testoffset("absolute", function( jQuery ) {
// get offset tests
var 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 }
{ 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() {
equals( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
@ -69,10 +69,10 @@ testoffset("absolute", function( jQuery ) {
// 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 }
{ 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() {
equals( jQuery( this.id ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
@ -80,29 +80,29 @@ testoffset("absolute", function( jQuery ) {
});
// test #5781
var offset = jQuery( '#positionTest' ).offset({ top: 10, left: 10 }).offset();
var offset = jQuery( "#positionTest" ).offset({ top: 10, left: 10 }).offset();
equals( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." )
equals( 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 }
{ 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() {
jQuery( this.id ).offset({ top: this.top, left: this.left });
@ -144,9 +144,9 @@ testoffset("relative", function( jQuery ) {
// get offset
var tests = [
{ id: '#relative-1', top: ie ? 6 : 7, left: 7 },
{ id: '#relative-1-1', top: ie ? 13 : 15, left: 15 },
{ id: '#relative-2', top: ie ? 141 : 142, left: 27 }
{ id: "#relative-1", top: ie ? 6 : 7, left: 7 },
{ id: "#relative-1-1", top: ie ? 13 : 15, left: 15 },
{ id: "#relative-2", top: ie ? 141 : 142, left: 27 }
];
jQuery.each( tests, function() {
equals( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
@ -156,9 +156,9 @@ testoffset("relative", function( jQuery ) {
// get position
tests = [
{ id: '#relative-1', top: ie ? 5 : 6, left: 6 },
{ id: '#relative-1-1', top: ie ? 4 : 5, left: 5 },
{ id: '#relative-2', top: ie ? 140 : 141, left: 26 }
{ id: "#relative-1", top: ie ? 5 : 6, left: 6 },
{ id: "#relative-1-1", top: ie ? 4 : 5, left: 5 },
{ id: "#relative-2", top: ie ? 140 : 141, left: 26 }
];
jQuery.each( tests, function() {
equals( jQuery( this.id ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
@ -168,18 +168,18 @@ testoffset("relative", function( jQuery ) {
// 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 }
{ 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() {
jQuery( this.id ).offset({ top: this.top, left: this.left });
@ -205,10 +205,10 @@ testoffset("static", function( jQuery ) {
// get offset
var tests = [
{ id: '#static-1', top: ie ? 6 : 7, left: 7 },
{ id: '#static-1-1', top: ie ? 13 : 15, left: 15 },
{ id: '#static-1-1-1', top: ie ? 20 : 23, left: 23 },
{ id: '#static-2', top: ie ? 121 : 122, left: 7 }
{ id: "#static-1", top: ie ? 6 : 7, left: 7 },
{ id: "#static-1-1", top: ie ? 13 : 15, left: 15 },
{ id: "#static-1-1-1", top: ie ? 20 : 23, left: 23 },
{ id: "#static-2", top: ie ? 121 : 122, left: 7 }
];
jQuery.each( tests, function() {
equals( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
@ -218,10 +218,10 @@ testoffset("static", function( jQuery ) {
// get position
tests = [
{ id: '#static-1', top: ie ? 5 : 6, left: 6 },
{ id: '#static-1-1', top: ie ? 12 : 14, left: 14 },
{ id: '#static-1-1-1', top: ie ? 19 : 22, left: 22 },
{ id: '#static-2', top: ie ? 120 : 121, left: 6 }
{ id: "#static-1", top: ie ? 5 : 6, left: 6 },
{ id: "#static-1-1", top: ie ? 12 : 14, left: 14 },
{ id: "#static-1-1-1", top: ie ? 19 : 22, left: 22 },
{ id: "#static-2", top: ie ? 120 : 121, left: 6 }
];
jQuery.each( tests, function() {
equals( jQuery( this.id ).position().top, this.top, "jQuery('" + this.top + "').position().top" );
@ -231,22 +231,22 @@ testoffset("static", function( jQuery ) {
// 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 }
{ 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() {
jQuery( this.id ).offset({ top: this.top, left: this.left });
@ -270,8 +270,8 @@ testoffset("fixed", function( jQuery ) {
jQuery.offset.initialize();
var tests = [
{ id: '#fixed-1', top: 1001, left: 1001 },
{ id: '#fixed-2', top: 1021, left: 1021 }
{ id: "#fixed-1", top: 1001, left: 1001 },
{ id: "#fixed-2", top: 1021, left: 1021 }
];
jQuery.each( tests, function() {
@ -284,18 +284,18 @@ testoffset("fixed", function( jQuery ) {
equals( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
} else {
// need to have same number of assertions
ok( true, 'Fixed position is not supported' );
ok( true, 'Fixed position is not supported' );
ok( true, "Fixed position is not supported" );
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 }
{ 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() {
@ -314,33 +314,33 @@ testoffset("fixed", function( jQuery ) {
equals( jQuery( 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
ok( true, 'Fixed position is not supported' );
ok( true, 'Fixed position is not supported' );
ok( true, 'Fixed position is not supported' );
ok( true, 'Fixed position is not supported' );
ok( true, "Fixed position is not supported" );
ok( true, "Fixed position is not supported" );
ok( true, "Fixed position is not supported" );
ok( true, "Fixed position is not supported" );
}
});
// Bug 8316
var $noTopLeft = jQuery('#fixed-no-top-left');
var $noTopLeft = jQuery("#fixed-no-top-left");
if ( jQuery.offset.supportsFixedPosition ) {
equals( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
equals( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
} else {
// need to have same number of assertions
ok( true, 'Fixed position is not supported' );
ok( true, 'Fixed position is not supported' );
ok( true, "Fixed position is not supported" );
ok( true, "Fixed position is not supported" );
}
});
testoffset("table", function( jQuery ) {
expect(4);
equals( jQuery('#table-1').offset().top, 6, "jQuery('#table-1').offset().top" );
equals( jQuery('#table-1').offset().left, 6, "jQuery('#table-1').offset().left" );
equals( jQuery("#table-1").offset().top, 6, "jQuery('#table-1').offset().top" );
equals( jQuery("#table-1").offset().left, 6, "jQuery('#table-1').offset().left" );
equals( jQuery('#th-1').offset().top, 10, "jQuery('#th-1').offset().top" );
equals( jQuery('#th-1').offset().left, 10, "jQuery('#th-1').offset().left" );
equals( jQuery("#th-1").offset().top, 10, "jQuery('#th-1').offset().top" );
equals( jQuery("#th-1").offset().left, 10, "jQuery('#th-1').offset().left" );
});
testoffset("scroll", function( jQuery, win ) {
@ -349,23 +349,23 @@ testoffset("scroll", function( jQuery, win ) {
var ie = jQuery.browser.msie && parseInt( jQuery.browser.version, 10 ) < 8;
// IE is collapsing the top margin of 1px
equals( jQuery('#scroll-1').offset().top, ie ? 6 : 7, "jQuery('#scroll-1').offset().top" );
equals( jQuery('#scroll-1').offset().left, 7, "jQuery('#scroll-1').offset().left" );
equals( jQuery("#scroll-1").offset().top, ie ? 6 : 7, "jQuery('#scroll-1').offset().top" );
equals( jQuery("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
// IE is collapsing the top margin of 1px
equals( jQuery('#scroll-1-1').offset().top, ie ? 9 : 11, "jQuery('#scroll-1-1').offset().top" );
equals( jQuery('#scroll-1-1').offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
equals( jQuery("#scroll-1-1").offset().top, ie ? 9 : 11, "jQuery('#scroll-1-1').offset().top" );
equals( jQuery("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
// scroll offset tests .scrollTop/Left
equals( jQuery('#scroll-1').scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
equals( jQuery('#scroll-1').scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
equals( jQuery("#scroll-1").scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
equals( jQuery("#scroll-1").scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
equals( jQuery('#scroll-1-1').scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
equals( jQuery('#scroll-1-1').scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
equals( jQuery("#scroll-1-1").scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
equals( jQuery("#scroll-1-1").scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
// equals( jQuery('body').scrollTop(), 0, "jQuery('body').scrollTop()" );
// equals( jQuery('body').scrollLeft(), 0, "jQuery('body').scrollTop()" );
// equals( jQuery("body").scrollTop(), 0, "jQuery("body").scrollTop()" );
// equals( jQuery("body").scrollLeft(), 0, "jQuery("body").scrollTop()" );
win.name = "test";
@ -395,8 +395,8 @@ testoffset("scroll", function( jQuery, win ) {
testoffset("body", function( jQuery ) {
expect(2);
equals( jQuery('body').offset().top, 1, "jQuery('#body').offset().top" );
equals( jQuery('body').offset().left, 1, "jQuery('#body').offset().left" );
equals( jQuery("body").offset().top, 1, "jQuery('#body').offset().top" );
equals( jQuery("body").offset().left, 1, "jQuery('#body').offset().left" );
});
test("Chaining offset(coords) returns jQuery object", function() {
@ -456,10 +456,10 @@ function testoffset( name, fn ) {
});
function loadFixture() {
var src = './data/offset/' + name + '.html?' + parseInt( Math.random()*1000, 10 ),
iframe = jQuery('<iframe />').css({
width: 500, height: 500, position: 'absolute', top: -600, left: -600, visibility: 'hidden'
}).appendTo('body')[0];
var src = "./data/offset/" + name + ".html?" + parseInt( Math.random()*1000, 10 ),
iframe = jQuery("<iframe />").css({
width: 500, height: 500, position: "absolute", top: -600, left: -600, visibility: "hidden"
}).appendTo("body")[0];
iframe.contentWindow.location = src;
return iframe;
}

View File

@ -7,32 +7,32 @@ test("queue() with other types",function() {
var $div = jQuery({});
$div
.queue('foo',function(){
.queue("foo",function(){
equals( ++counter, 1, "Dequeuing" );
jQuery.dequeue(this,'foo');
jQuery.dequeue(this,"foo");
})
.queue('foo',function(){
.queue("foo",function(){
equals( ++counter, 2, "Dequeuing" );
jQuery(this).dequeue('foo');
jQuery(this).dequeue("foo");
})
.queue('foo',function(){
.queue("foo",function(){
equals( ++counter, 3, "Dequeuing" );
})
.queue('foo',function(){
.queue("foo",function(){
equals( ++counter, 4, "Dequeuing" );
});
equals( $div.queue('foo').length, 4, "Testing queue length" );
equals( $div.queue("foo").length, 4, "Testing queue length" );
$div.dequeue('foo');
$div.dequeue("foo");
equals( counter, 3, "Testing previous call to dequeue" );
equals( $div.queue('foo').length, 1, "Testing queue length" );
equals( $div.queue("foo").length, 1, "Testing queue length" );
$div.dequeue('foo');
$div.dequeue("foo");
equals( counter, 4, "Testing previous call to dequeue" );
equals( $div.queue('foo').length, 0, "Testing queue length" );
equals( $div.queue("foo").length, 0, "Testing queue length" );
});
test("queue(name) passes in the next item in the queue as a parameter", function() {

View File

@ -2,7 +2,7 @@ module("traversing", { teardown: moduleTeardown });
test("find(String)", function() {
expect(5);
equals( 'Yahoo', jQuery('#foo').find('.blogTest').text(), 'Check for find' );
equals( "Yahoo", jQuery("#foo").find(".blogTest").text(), "Check for find" );
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
@ -16,89 +16,89 @@ test("find(String)", function() {
test("find(node|jQuery object)", function() {
expect( 11 );
var $foo = jQuery('#foo'),
$blog = jQuery('.blogTest'),
$first = jQuery('#first'),
var $foo = jQuery("#foo"),
$blog = jQuery(".blogTest"),
$first = jQuery("#first"),
$two = $blog.add( $first ),
$fooTwo = $foo.add( $blog );
equals( $foo.find( $blog ).text(), 'Yahoo', 'Find with blog jQuery object' );
equals( $foo.find( $blog[0] ).text(), 'Yahoo', 'Find with blog node' );
equals( $foo.find( $first ).length, 0, '#first is not in #foo' );
equals( $foo.find( $first[0]).length, 0, '#first not in #foo (node)' );
ok( $foo.find( $two ).is('.blogTest'), 'Find returns only nodes within #foo' );
ok( $fooTwo.find( $blog ).is('.blogTest'), 'Blog is part of the collection, but also within foo' );
ok( $fooTwo.find( $blog[0] ).is('.blogTest'), 'Blog is part of the collection, but also within foo(node)' );
equals( $foo.find( $blog ).text(), "Yahoo", "Find with blog jQuery object" );
equals( $foo.find( $blog[0] ).text(), "Yahoo", "Find with blog node" );
equals( $foo.find( $first ).length, 0, "#first is not in #foo" );
equals( $foo.find( $first[0]).length, 0, "#first not in #foo (node)" );
ok( $foo.find( $two ).is(".blogTest"), "Find returns only nodes within #foo" );
ok( $fooTwo.find( $blog ).is(".blogTest"), "Blog is part of the collection, but also within foo" );
ok( $fooTwo.find( $blog[0] ).is(".blogTest"), "Blog is part of the collection, but also within foo(node)" );
equals( $two.find( $foo ).length, 0, 'Foo is not in two elements' );
equals( $two.find( $foo[0] ).length, 0, 'Foo is not in two elements(node)' );
equals( $two.find( $first ).length, 0, 'first is in the collection and not within two' );
equals( $two.find( $first ).length, 0, 'first is in the collection and not within two(node)' );
equals( $two.find( $foo ).length, 0, "Foo is not in two elements" );
equals( $two.find( $foo[0] ).length, 0, "Foo is not in two elements(node)" );
equals( $two.find( $first ).length, 0, "first is in the collection and not within two" );
equals( $two.find( $first ).length, 0, "first is in the collection and not within two(node)" );
});
test("is(String|undefined)", function() {
expect(27);
ok( jQuery('#form').is('form'), 'Check for element: A form must be a form' );
ok( !jQuery('#form').is('div'), 'Check for element: A form is not a div' );
ok( jQuery('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
ok( !jQuery('#mark').is('.link'), 'Check for class: Did not expect class "link"' );
ok( jQuery('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );
ok( !jQuery('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
ok( jQuery('#en').is('[lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );
ok( !jQuery('#en').is('[lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
ok( jQuery('#text1').is('[type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );
ok( !jQuery('#text1').is('[type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
ok( jQuery('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );
ok( !jQuery('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );
ok( jQuery('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );
ok( !jQuery('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );
ok( jQuery('#foo').is(':has(p)'), 'Check for child: Expected a child "p" element' );
ok( !jQuery('#foo').is(':has(ul)'), 'Check for child: Did not expect "ul" element' );
ok( jQuery('#foo').is(':has(p):has(a):has(code)'), 'Check for childs: Expected "p", "a" and "code" child elements' );
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"' );
ok( jQuery("#form").is("form"), "Check for element: A form must be a form" );
ok( !jQuery("#form").is("div"), "Check for element: A form is not a div" );
ok( jQuery("#mark").is(".blog"), "Check for class: Expected class 'blog'" );
ok( !jQuery("#mark").is(".link"), "Check for class: Did not expect class 'link'" );
ok( jQuery("#simon").is(".blog.link"), "Check for multiple classes: Expected classes 'blog' and 'link'" );
ok( !jQuery("#simon").is(".blogTest"), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
ok( jQuery("#en").is("[lang=\"en\"]"), "Check for attribute: Expected attribute lang to be 'en'" );
ok( !jQuery("#en").is("[lang=\"de\"]"), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
ok( jQuery("#text1").is("[type=\"text\"]"), "Check for attribute: Expected attribute type to be 'text'" );
ok( !jQuery("#text1").is("[type=\"radio\"]"), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
ok( jQuery("#text2").is(":disabled"), "Check for pseudoclass: Expected to be disabled" );
ok( !jQuery("#text1").is(":disabled"), "Check for pseudoclass: Expected not disabled" );
ok( jQuery("#radio2").is(":checked"), "Check for pseudoclass: Expected to be checked" );
ok( !jQuery("#radio1").is(":checked"), "Check for pseudoclass: Expected not checked" );
ok( jQuery("#foo").is(":has(p)"), "Check for child: Expected a child 'p' element" );
ok( !jQuery("#foo").is(":has(ul)"), "Check for child: Did not expect 'ul' element" );
ok( jQuery("#foo").is(":has(p):has(a):has(code)"), "Check for childs: Expected 'p', 'a' and 'code' child elements" );
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'" );
ok( !jQuery('#foo').is(0), 'Expected false for an invalid expression - 0' );
ok( !jQuery('#foo').is(null), 'Expected false for an invalid expression - null' );
ok( !jQuery('#foo').is(''), 'Expected false for an invalid expression - ""' );
ok( !jQuery('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
ok( !jQuery('#foo').is({ plain: "object" }), 'Check passing invalid object' );
ok( !jQuery("#foo").is(0), "Expected false for an invalid expression - 0" );
ok( !jQuery("#foo").is(null), "Expected false for an invalid expression - null" );
ok( !jQuery("#foo").is(""), "Expected false for an invalid expression - \"\"" );
ok( !jQuery("#foo").is(undefined), "Expected false for an invalid expression - undefined" );
ok( !jQuery("#foo").is({ plain: "object" }), "Check passing invalid object" );
// test is() with comma-seperated expressions
ok( jQuery('#en').is('[lang="en"],[lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
ok( jQuery('#en').is('[lang="de"],[lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
ok( jQuery('#en').is('[lang="en"] , [lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
ok( jQuery('#en').is('[lang="de"] , [lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
ok( jQuery("#en").is("[lang=\"en\"],[lang=\"de\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
ok( jQuery("#en").is("[lang=\"de\"],[lang=\"en\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
ok( jQuery("#en").is("[lang=\"en\"] , [lang=\"de\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
ok( jQuery("#en").is("[lang=\"de\"] , [lang=\"en\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
});
test("is(jQuery)", function() {
expect(24);
ok( jQuery('#form').is( jQuery('form') ), 'Check for element: A form is a form' );
ok( !jQuery('#form').is( jQuery('div') ), 'Check for element: A form is not a div' );
ok( jQuery('#mark').is( jQuery('.blog') ), 'Check for class: Expected class "blog"' );
ok( !jQuery('#mark').is( jQuery('.link') ), 'Check for class: Did not expect class "link"' );
ok( jQuery('#simon').is( jQuery('.blog.link') ), 'Check for multiple classes: Expected classes "blog" and "link"' );
ok( !jQuery('#simon').is( jQuery('.blogTest') ), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
ok( jQuery('#en').is( jQuery('[lang="en"]') ), 'Check for attribute: Expected attribute lang to be "en"' );
ok( !jQuery('#en').is( jQuery('[lang="de"]') ), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
ok( jQuery('#text1').is( jQuery('[type="text"]') ), 'Check for attribute: Expected attribute type to be "text"' );
ok( !jQuery('#text1').is( jQuery('[type="radio"]') ), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
ok( jQuery('#text2').is( jQuery(':disabled') ), 'Check for pseudoclass: Expected to be disabled' );
ok( !jQuery('#text1').is( jQuery(':disabled') ), 'Check for pseudoclass: Expected not disabled' );
ok( jQuery('#radio2').is( jQuery(':checked') ), 'Check for pseudoclass: Expected to be checked' );
ok( !jQuery('#radio1').is( jQuery(':checked') ), 'Check for pseudoclass: Expected not checked' );
ok( jQuery('#foo').is( jQuery(':has(p)') ), 'Check for child: Expected a child "p" element' );
ok( !jQuery('#foo').is( jQuery(':has(ul)') ), 'Check for child: Did not expect "ul" element' );
ok( jQuery('#foo').is( jQuery(':has(p):has(a):has(code)') ), 'Check for childs: Expected "p", "a" and "code" child elements' );
ok( !jQuery('#foo').is( jQuery(':has(p):has(a):has(code):has(ol)') ), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
ok( jQuery("#form").is( jQuery("form") ), "Check for element: A form is a form" );
ok( !jQuery("#form").is( jQuery("div") ), "Check for element: A form is not a div" );
ok( jQuery("#mark").is( jQuery(".blog") ), "Check for class: Expected class 'blog'" );
ok( !jQuery("#mark").is( jQuery(".link") ), "Check for class: Did not expect class 'link'" );
ok( jQuery("#simon").is( jQuery(".blog.link") ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
ok( !jQuery("#simon").is( jQuery(".blogTest") ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
ok( jQuery("#en").is( jQuery("[lang=\"en\"]") ), "Check for attribute: Expected attribute lang to be 'en'" );
ok( !jQuery("#en").is( jQuery("[lang=\"de\"]") ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
ok( jQuery("#text1").is( jQuery("[type=\"text\"]") ), "Check for attribute: Expected attribute type to be 'text'" );
ok( !jQuery("#text1").is( jQuery("[type=\"radio\"]") ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
ok( jQuery("#text2").is( jQuery(":disabled") ), "Check for pseudoclass: Expected to be disabled" );
ok( !jQuery("#text1").is( jQuery(":disabled") ), "Check for pseudoclass: Expected not disabled" );
ok( jQuery("#radio2").is( jQuery(":checked") ), "Check for pseudoclass: Expected to be checked" );
ok( !jQuery("#radio1").is( jQuery(":checked") ), "Check for pseudoclass: Expected not checked" );
ok( jQuery("#foo").is( jQuery(":has(p)") ), "Check for child: Expected a child 'p' element" );
ok( !jQuery("#foo").is( jQuery(":has(ul)") ), "Check for child: Did not expect 'ul' element" );
ok( jQuery("#foo").is( jQuery(":has(p):has(a):has(code)") ), "Check for childs: Expected 'p', 'a' and 'code' child elements" );
ok( !jQuery("#foo").is( jQuery(":has(p):has(a):has(code):has(ol)") ), "Check for childs: Expected 'p', 'a' and 'code' child elements, but no 'ol'" );
// Some raw elements
ok( jQuery('#form').is( jQuery('form')[0] ), 'Check for element: A form is a form' );
ok( !jQuery('#form').is( jQuery('div')[0] ), 'Check for element: A form is not a div' );
ok( jQuery('#mark').is( jQuery('.blog')[0] ), 'Check for class: Expected class "blog"' );
ok( !jQuery('#mark').is( jQuery('.link')[0] ), 'Check for class: Did not expect class "link"' );
ok( jQuery('#simon').is( jQuery('.blog.link')[0] ), 'Check for multiple classes: Expected classes "blog" and "link"' );
ok( !jQuery('#simon').is( jQuery('.blogTest')[0] ), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
ok( jQuery("#form").is( jQuery("form")[0] ), "Check for element: A form is a form" );
ok( !jQuery("#form").is( jQuery("div")[0] ), "Check for element: A form is not a div" );
ok( jQuery("#mark").is( jQuery(".blog")[0] ), "Check for class: Expected class 'blog'" );
ok( !jQuery("#mark").is( jQuery(".link")[0] ), "Check for class: Did not expect class 'link'" );
ok( jQuery("#simon").is( jQuery(".blog.link")[0] ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
ok( !jQuery("#simon").is( jQuery(".blogTest")[0] ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
});
test("index()", function() {
@ -111,15 +111,15 @@ test("index(Object|String|undefined)", function() {
expect(16);
var elements = jQuery([window, document]),
inputElements = jQuery('#radio1,#radio2,#check1,#check2');
inputElements = jQuery("#radio1,#radio2,#check1,#check2");
// Passing a node
equals( elements.index(window), 0, "Check for index of elements" );
equals( elements.index(document), 1, "Check for index of elements" );
equals( inputElements.index(document.getElementById('radio1')), 0, "Check for index of elements" );
equals( inputElements.index(document.getElementById('radio2')), 1, "Check for index of elements" );
equals( inputElements.index(document.getElementById('check1')), 2, "Check for index of elements" );
equals( inputElements.index(document.getElementById('check2')), 3, "Check for index of elements" );
equals( inputElements.index(document.getElementById("radio1")), 0, "Check for index of elements" );
equals( inputElements.index(document.getElementById("radio2")), 1, "Check for index of elements" );
equals( inputElements.index(document.getElementById("check1")), 2, "Check for index of elements" );
equals( inputElements.index(document.getElementById("check2")), 3, "Check for index of elements" );
equals( inputElements.index(window), -1, "Check for not found index" );
equals( inputElements.index(document), -1, "Check for not found index" );
@ -131,11 +131,11 @@ test("index(Object|String|undefined)", function() {
// Passing a selector or nothing
// enabled since [6330]
equals( jQuery('#text2').index(), 2, "Check for index amongst siblings" );
equals( jQuery('#form').children().eq(4).index(), 4, "Check for index amongst siblings" );
equals( jQuery('#radio2').index('#form :radio') , 1, "Check for index within a selector" );
equals( jQuery('#form :radio').index( jQuery('#radio2') ), 1, "Check for index within a selector" );
equals( jQuery('#radio2').index('#form :text') , -1, "Check for index not found within a selector" );
equals( jQuery("#text2").index(), 2, "Check for index amongst siblings" );
equals( jQuery("#form").children().eq(4).index(), 4, "Check for index amongst siblings" );
equals( jQuery("#radio2").index("#form :radio") , 1, "Check for index within a selector" );
equals( jQuery("#form :radio").index( jQuery("#radio2") ), 1, "Check for index within a selector" );
equals( jQuery("#radio2").index("#form :text") , -1, "Check for index not found within a selector" );
});
test("filter(Selector|undefined)", function() {
@ -144,10 +144,10 @@ test("filter(Selector|undefined)", function() {
same( jQuery("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );
same( jQuery("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );
same( jQuery('p').filter(null).get(), [], "filter(null) should return an empty jQuery object");
same( jQuery('p').filter(undefined).get(), [], "filter(undefined) should return an empty jQuery object");
same( jQuery('p').filter(0).get(), [], "filter(0) should return an empty jQuery object");
same( jQuery('p').filter('').get(), [], "filter('') should return an empty jQuery object");
same( jQuery("p").filter(null).get(), [], "filter(null) should return an empty jQuery object");
same( jQuery("p").filter(undefined).get(), [], "filter(undefined) should return an empty jQuery object");
same( jQuery("p").filter(0).get(), [], "filter(0) should return an empty jQuery object");
same( 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();
@ -201,14 +201,14 @@ test("closest()", function() {
same( jq.closest("#nothiddendiv", document.body).get(), q("nothiddendiv"), "Context not reached." );
//Test that .closest() returns unique'd set
equals( jQuery('#main p').closest('#main').length, 1, "Closest should return a unique set" );
equals( jQuery("#main p").closest("#main").length, 1, "Closest should return a unique set" );
// Test on disconnected node
equals( jQuery("<div><p></p></div>").find("p").closest("table").length, 0, "Make sure disconnected closest work." );
// Bug #7369
equals( jQuery('<div foo="bar"></div>').closest('[foo]').length, 1, "Disconnected nodes with attribute selector" );
equals( jQuery('<div>text</div>').closest('[lang]').length, 0, "Disconnected nodes with text and non-existent attribute selector" );
equals( jQuery("<div foo='bar'></div>").closest("[foo]").length, 1, "Disconnected nodes with attribute selector" );
equals( jQuery("<div>text</div>").closest("[lang]").length, 0, "Disconnected nodes with text and non-existent attribute selector" );
});
test("closest(Array)", function() {
@ -233,14 +233,14 @@ test("closest(jQuery)", function() {
$parent = jQuery("#nothiddendiv"),
$main = jQuery("#main"),
$body = jQuery("body");
ok( $child.closest( $parent ).is('#nothiddendiv'), "closest( jQuery('#nothiddendiv') )" );
ok( $child.closest( $parent[0] ).is('#nothiddendiv'), "closest( jQuery('#nothiddendiv') ) :: node" );
ok( $child.closest( $child ).is('#nothiddendivchild'), "child is included" );
ok( $child.closest( $child[0] ).is('#nothiddendivchild'), "child is included :: node" );
equals( $child.closest( document.createElement('div') ).length, 0, "created element is not related" );
ok( $child.closest( $parent ).is("#nothiddendiv"), "closest( jQuery('#nothiddendiv') )" );
ok( $child.closest( $parent[0] ).is("#nothiddendiv"), "closest( jQuery('#nothiddendiv') ) :: node" );
ok( $child.closest( $child ).is("#nothiddendivchild"), "child is included" );
ok( $child.closest( $child[0] ).is("#nothiddendivchild"), "child is included :: node" );
equals( $child.closest( document.createElement("div") ).length, 0, "created element is not related" );
equals( $child.closest( $main ).length, 0, "Main not a parent of child" );
equals( $child.closest( $main[0] ).length, 0, "Main not a parent of child :: node" );
ok( $child.closest( $body.add($parent) ).is('#nothiddendiv'), "Closest ancestor retrieved." );
ok( $child.closest( $body.add($parent) ).is("#nothiddendiv"), "Closest ancestor retrieved." );
});
test("not(Selector)", function() {
@ -251,15 +251,15 @@ test("not(Selector)", function() {
same( jQuery("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );
same( jQuery("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d", "option3e", "option4e","option5b"), "not('complex selector')");
same( jQuery('#ap *').not('code').get(), q("google", "groups", "anchor1", "mark"), "not('tag selector')" );
same( jQuery('#ap *').not('code, #mark').get(), q("google", "groups", "anchor1"), "not('tag, ID selector')" );
same( jQuery('#ap *').not('#mark, code').get(), q("google", "groups", "anchor1"), "not('ID, tag selector')");
same( jQuery("#ap *").not("code").get(), q("google", "groups", "anchor1", "mark"), "not('tag selector')" );
same( jQuery("#ap *").not("code, #mark").get(), q("google", "groups", "anchor1"), "not('tag, ID selector')" );
same( jQuery("#ap *").not("#mark, code").get(), q("google", "groups", "anchor1"), "not('ID, tag selector')");
var all = jQuery('p').get();
same( jQuery('p').not(null).get(), all, "not(null) should have no effect");
same( jQuery('p').not(undefined).get(), all, "not(undefined) should have no effect");
same( jQuery('p').not(0).get(), all, "not(0) should have no effect");
same( jQuery('p').not('').get(), all, "not('') should have no effect");
var all = jQuery("p").get();
same( jQuery("p").not(null).get(), all, "not(null) should have no effect");
same( jQuery("p").not(undefined).get(), all, "not(undefined) should have no effect");
same( jQuery("p").not(0).get(), all, "not(0) should have no effect");
same( jQuery("p").not("").get(), all, "not('') should have no effect");
});
test("not(Element)", function() {
@ -372,7 +372,7 @@ test("parentsUntil([String])", function() {
same( jQuery("#groups").parentsUntil().get(), parents.get(), "parentsUntil with no selector (nextAll)" );
same( jQuery("#groups").parentsUntil(".foo").get(), parents.get(), "parentsUntil with invalid selector (nextAll)" );
same( jQuery("#groups").parentsUntil("#html").get(), parents.not(':last').get(), "Simple parentsUntil check" );
same( jQuery("#groups").parentsUntil("#html").get(), parents.not(":last").get(), "Simple parentsUntil check" );
equals( jQuery("#groups").parentsUntil("#ap").length, 0, "Simple parentsUntil check" );
same( jQuery("#groups").parentsUntil("#html, #body").get(), parents.slice( 0, 3 ).get(), "Less simple parentsUntil check" );
same( jQuery("#groups").parentsUntil("#html", "div").get(), jQuery("#main").get(), "Filtered parentsUntil check" );
@ -400,29 +400,29 @@ test("prev([String])", function() {
test("nextAll([String])", function() {
expect(4);
var elems = jQuery('#form').children();
var elems = jQuery("#form").children();
same( jQuery("#label-for").nextAll().get(), elems.not(':first').get(), "Simple nextAll check" );
same( jQuery("#label-for").nextAll('input').get(), elems.not(':first').filter('input').get(), "Filtered nextAll check" );
same( jQuery("#label-for").nextAll('input,select').get(), elems.not(':first').filter('input,select').get(), "Multiple-filtered nextAll check" );
same( jQuery("#label-for, #hidden1").nextAll('input,select').get(), elems.not(':first').filter('input,select').get(), "Multi-source, multiple-filtered nextAll check" );
same( jQuery("#label-for").nextAll().get(), elems.not(":first").get(), "Simple nextAll check" );
same( jQuery("#label-for").nextAll("input").get(), elems.not(":first").filter("input").get(), "Filtered nextAll check" );
same( jQuery("#label-for").nextAll("input,select").get(), elems.not(":first").filter("input,select").get(), "Multiple-filtered nextAll check" );
same( jQuery("#label-for, #hidden1").nextAll("input,select").get(), elems.not(":first").filter("input,select").get(), "Multi-source, multiple-filtered nextAll check" );
});
test("prevAll([String])", function() {
expect(4);
var elems = jQuery( jQuery('#form').children().slice(0, 12).get().reverse() );
var elems = jQuery( jQuery("#form").children().slice(0, 12).get().reverse() );
same( jQuery("#area1").prevAll().get(), elems.get(), "Simple prevAll check" );
same( jQuery("#area1").prevAll('input').get(), elems.filter('input').get(), "Filtered prevAll check" );
same( jQuery("#area1").prevAll('input,select').get(), elems.filter('input,select').get(), "Multiple-filtered prevAll check" );
same( jQuery("#area1, #hidden1").prevAll('input,select').get(), elems.filter('input,select').get(), "Multi-source, multiple-filtered prevAll check" );
same( jQuery("#area1").prevAll("input").get(), elems.filter("input").get(), "Filtered prevAll check" );
same( jQuery("#area1").prevAll("input,select").get(), elems.filter("input,select").get(), "Multiple-filtered prevAll check" );
same( jQuery("#area1, #hidden1").prevAll("input,select").get(), elems.filter("input,select").get(), "Multi-source, multiple-filtered prevAll check" );
});
test("nextUntil([String])", function() {
expect(11);
var elems = jQuery('#form').children().slice( 2, 12 );
var elems = jQuery("#form").children().slice( 2, 12 );
same( jQuery("#text1").nextUntil().get(), jQuery("#text1").nextAll().get(), "nextUntil with no selector (nextAll)" );
same( jQuery("#text1").nextUntil(".foo").get(), jQuery("#text1").nextAll().get(), "nextUntil with invalid selector (nextAll)" );
@ -445,14 +445,14 @@ test("prevUntil([String])", function() {
same( jQuery("#area1").prevUntil().get(), elems.get(), "prevUntil with no selector (prevAll)" );
same( jQuery("#area1").prevUntil(".foo").get(), elems.get(), "prevUntil with invalid selector (prevAll)" );
same( jQuery("#area1").prevUntil("label").get(), elems.not(':last').get(), "Simple prevUntil check" );
same( jQuery("#area1").prevUntil("label").get(), elems.not(":last").get(), "Simple prevUntil check" );
equals( jQuery("#area1").prevUntil("#button").length, 0, "Simple prevUntil check" );
same( jQuery("#area1").prevUntil("label, #search").get(), jQuery("#area1").prev().get(), "Less simple prevUntil check" );
same( jQuery("#area1").prevUntil("label", "input").get(), elems.not(':last').not("button").get(), "Filtered prevUntil check" );
same( jQuery("#area1").prevUntil("label", "button").get(), elems.not(':last').not("input").get(), "Filtered prevUntil check" );
same( jQuery("#area1").prevUntil("label", "button,input").get(), elems.not(':last').get(), "Multiple-filtered prevUntil check" );
same( jQuery("#area1").prevUntil("label", "input").get(), elems.not(":last").not("button").get(), "Filtered prevUntil check" );
same( jQuery("#area1").prevUntil("label", "button").get(), elems.not(":last").not("input").get(), "Filtered prevUntil check" );
same( jQuery("#area1").prevUntil("label", "button,input").get(), elems.not(":last").get(), "Multiple-filtered prevUntil check" );
equals( jQuery("#area1").prevUntil("label", "div").length, 0, "Filtered prevUntil check, no match" );
same( jQuery("#area1, #hidden1").prevUntil("label", "button,input").get(), elems.not(':last').get(), "Multi-source, multiple-filtered prevUntil check" );
same( jQuery("#area1, #hidden1").prevUntil("label", "button,input").get(), elems.not(":last").get(), "Multi-source, multiple-filtered prevUntil check" );
});
test("contents()", function() {
@ -527,7 +527,7 @@ test("add(String|Element|Array|undefined)", function() {
var notDefined;
equals( jQuery([]).add(notDefined).length, 0, "Check that undefined adds nothing" );
ok( jQuery([]).add( document.getElementById('form') ).length >= 13, "Add a form (adds the elements)" );
ok( jQuery([]).add( document.getElementById("form") ).length >= 13, "Add a form (adds the elements)" );
});
test("add(String, Context)", function() {