});\r
\r
test("isFunction", function() {\r
- expect(21);\r
+ expect(19);\r
\r
// Make sure that false values return false\r
ok( !jQuery.isFunction(), "No Value" );\r
ok( !jQuery.isFunction(obj), "Object Element" );\r
\r
// IE says this is an object\r
- ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" );\r
+ // Since 1.3, this isn't supported (#2968)\r
+ //ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" );\r
\r
var nodes = document.body.childNodes;\r
\r
document.body.appendChild( input );\r
\r
// IE says this is an object\r
- ok( jQuery.isFunction(input.focus), "A default function property" );\r
+ // Since 1.3, this isn't supported (#2968)\r
+ //ok( jQuery.isFunction(input.focus), "A default function property" );\r
\r
document.body.removeChild( input );\r
\r
});\r
\r
test("val()", function() {\r
- expect(3);\r
+ expect(8);\r
+\r
equals( jQuery("#text1").val(), "Test", "Check for value of input element" );\r
// ticket #1714 this caused a JS error in IE\r
equals( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );\r
ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );\r
+ \r
+ equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' );\r
+\r
+ isSet( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' );\r
+\r
+ equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' );\r
+ \r
+ equals( jQuery('#option3a').val(), '', 'Call val() on a option element with empty value' );\r
+ \r
+ equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' );\r
+ \r
});\r
\r
test("val(String/Number)", function() {\r
var scriptorder = 0;\r
\r
test("html(String)", function() {\r
- expect(11);\r
+ expect(13);\r
var div = jQuery("#main > div");\r
div.html("<b>test</b>");\r
var pass = true;\r
jQuery("#main select").html("<option>O1</option><option selected='selected'>O2</option><option>O3</option>");\r
equals( jQuery("#main select").val(), "O2", "Selected option correct" );\r
\r
+ var $div = jQuery('<div />');\r
+ equals( $div.html( 5 ).html(), '5', 'Setting a number as html' );\r
+ equals( $div.html( 0 ).html(), '0', 'Setting a zero as html' );\r
+\r
stop();\r
\r
jQuery("#main").html('<script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script>');\r
isSet( jQuery("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );\r
isSet( jQuery("p").not(jQuery("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );\r
equals( jQuery("p").not(document.getElementsByTagName("p")).length, 0, "not(Array-like DOM collection)" );\r
- isSet( jQuery("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d" ), "not('complex selector')");\r
+ isSet( jQuery("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d", "option3e" ), "not('complex selector')");\r
\r
var selects = jQuery("#form select");\r
isSet( selects.not( selects[1] ), q("select1", "select3"), "filter out DOM element");\r
\r
test("removeClass(String) - simple", function() {\r
expect(4);\r
- var div = jQuery("div").addClass("test").removeClass("test"),\r
- pass = true;\r
- for ( var i = 0; i < div.size(); i++ ) {\r
- if ( div.get(i).className.indexOf("test") != -1 ) pass = false;\r
- }\r
- ok( pass, "Remove Class" );\r
+ \r
+ var $divs = jQuery('div');\r
+ \r
+ $divs.addClass("test").removeClass("test");\r
+ \r
+ ok( !$divs.is('.test'), "Remove Class" );\r
\r
reset();\r
- var div = jQuery("div").addClass("test").addClass("foo").addClass("bar");\r
- div.removeClass("test").removeClass("bar").removeClass("foo");\r
- var pass = true;\r
- for ( var i = 0; i < div.size(); i++ ) {\r
- if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;\r
- }\r
- ok( pass, "Remove multiple classes" );\r
+ \r
+ $divs.addClass("test").addClass("foo").addClass("bar");\r
+ $divs.removeClass("test").removeClass("bar").removeClass("foo");\r
+ \r
+ ok( !$divs.is('.test,.bar,.foo'), "Remove multiple classes" );\r
\r
reset();\r
- var div = jQuery("div:eq(0)").addClass("test").removeClass("");\r
- ok( div.is('.test'), "Empty string passed to removeClass" );\r
+ \r
+ $divs.eq(0).addClass("test").removeClass("");\r
+ ok( $divs.eq(0).is('.test'), "Empty string passed to removeClass" );\r
\r
// using contents will get regular, text, and comment nodes\r
var j = jQuery("#nonnodes").contents();\r
});\r
\r
test("slice()", function() {\r
- expect(5);\r
- isSet( jQuery("#ap a").slice(1,2), q("groups"), "slice(1,2)" );\r
- isSet( jQuery("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" );\r
- isSet( jQuery("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );\r
- isSet( jQuery("#ap a").slice(-1), q("mark"), "slice(-1)" );\r
+ expect(6);\r
+ \r
+ var $links = jQuery("#ap a");\r
+ \r
+ isSet( $links.slice(1,2), q("groups"), "slice(1,2)" );\r
+ isSet( $links.slice(1), q("groups", "anchor1", "mark"), "slice(1)" );\r
+ isSet( $links.slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );\r
+ isSet( $links.slice(-1), q("mark"), "slice(-1)" );\r
\r
- isSet( jQuery("#ap a").eq(1), q("groups"), "eq(1)" );\r
+ isSet( $links.eq(1), q("groups"), "eq(1)" );\r
+ \r
+ isSet( $links.eq('2'), q("anchor1"), "eq('2')" );\r
});\r
\r
test("map()", function() {\r
});\r
\r
test("jQuery.makeArray", function(){\r
- expect(15);\r
+ expect(14);\r
\r
equals( jQuery.makeArray(jQuery('html>*'))[0].nodeName, "HEAD", "Pass makeArray a jQuery object" );\r
\r
\r
ok( !!jQuery.makeArray( document.documentElement.childNodes ).slice(0,1)[0].nodeName, "Pass makeArray a childNodes array" );\r
\r
- //function, is tricky as it has length\r
- equals( jQuery.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" );\r
+ // function, is tricky as it has length\r
+ // NOTE: Due to the conflict with Scriptaculous (http://dev.jquery.com/ticket/3248)\r
+ // We remove support for functions since jQuery 1.3\r
+ //equals( jQuery.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" );\r
+ \r
//window, also has length\r
equals( jQuery.makeArray(window)[0], window, "Pass makeArray the window" );\r
\r