$('<p>\r\n</p>');\r
});\r
\r
+test("isFunction", function() {\r
+ expect(21);\r
+\r
+ // Make sure that false values return false\r
+ ok( !jQuery.isFunction(), "No Value" );\r
+ ok( !jQuery.isFunction( null ), "null Value" );\r
+ ok( !jQuery.isFunction( undefined ), "undefined Value" );\r
+ ok( !jQuery.isFunction( "" ), "Empty String Value" );\r
+ ok( !jQuery.isFunction( 0 ), "0 Value" );\r
+\r
+ // Check built-ins\r
+ // Safari uses "(Internal Function)"\r
+ ok( jQuery.isFunction(String), "String Function" );\r
+ ok( jQuery.isFunction(Array), "Array Function" );\r
+ ok( jQuery.isFunction(Object), "Object Function" );\r
+ ok( jQuery.isFunction(Function), "Function Function" );\r
+\r
+ // When stringified, this could be misinterpreted\r
+ var mystr = "function";\r
+ ok( !jQuery.isFunction(mystr), "Function String" );\r
+\r
+ // When stringified, this could be misinterpreted\r
+ var myarr = [ "function" ];\r
+ ok( !jQuery.isFunction(myarr), "Function Array" );\r
+\r
+ // When stringified, this could be misinterpreted\r
+ var myfunction = { "function": "test" };\r
+ ok( !jQuery.isFunction(myfunction), "Function Object" );\r
+\r
+ // Make sure normal functions still work\r
+ var fn = function(){};\r
+ ok( jQuery.isFunction(fn), "Normal Function" );\r
+\r
+ var obj = document.createElement("object");\r
+\r
+ // Firefox says this is a function\r
+ ok( !jQuery.isFunction(obj), "Object Element" );\r
+\r
+ // IE says this is an object\r
+ ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" );\r
+\r
+ var nodes = document.body.childNodes;\r
+\r
+ // Safari says this is a function\r
+ ok( !jQuery.isFunction(nodes), "childNodes Property" );\r
+\r
+ var first = document.body.firstChild;\r
+ \r
+ // Normal elements are reported ok everywhere\r
+ ok( !jQuery.isFunction(first), "A normal DOM Element" );\r
+\r
+ var input = document.createElement("input");\r
+ input.type = "text";\r
+ document.body.appendChild( input );\r
+\r
+ // IE says this is an object\r
+ ok( jQuery.isFunction(input.focus), "A default function property" );\r
+\r
+ document.body.removeChild( input );\r
+\r
+ var a = document.createElement("a");\r
+ a.href = "some-function";\r
+ document.body.appendChild( a );\r
+\r
+ // This serializes with the word 'function' in it\r
+ ok( !jQuery.isFunction(a), "Anchor Element" );\r
+\r
+ document.body.removeChild( a );\r
+\r
+ // Recursive function calls have lengths and array-like properties\r
+ function callme(callback){\r
+ function fn(response){\r
+ callback(response);\r
+ }\r
+\r
+ ok( jQuery.isFunction(fn), "Recursive Function Call" );\r
+\r
+ fn({ some: "data" });\r
+ };\r
+\r
+ callme(function(){\r
+ callme(function(){});\r
+ });\r
+});\r
+\r
test("length", function() {\r
ok( $("div").length == 2, "Get Number of Elements Found" );\r
});\r
ok( $('#name').attr('name') == "name", 'Check for name attribute' );\r
ok( $('#text1').attr('name') == "action", 'Check for name attribute' );\r
ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );\r
- ok( $('#anchor2').attr('href') == "#2", 'Check for non-absolute href (an anchor)' );\r
+ \r
+ $('<a id="tAnchor5"></a>').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path\r
+ ok( $('#tAnchor5').attr('href') == "#5", 'Check for non-absolute href (an anchor)' );\r
+ \r
stop();\r
$.get("data/dashboard.xml", function(xml) {\r
ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );\r
});\r
\r
test("append(String|Element|Array<Element>|jQuery)", function() {\r
- expect(9);\r
+ expect(11);\r
var defaultText = 'Try them out:'\r
var result = $('#first').append('<b>buga</b>');\r
ok( result.text() == defaultText + 'buga', 'Check if text appending works' );\r
ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );\r
\r
reset();\r
+ $("#sap").append( " text with spaces " );\r
+ ok( $("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );\r
+\r
+ reset();\r
ok( $("#sap").append([]), "Check for appending an empty array." );\r
ok( $("#sap").append(""), "Check for appending an empty string." );\r
ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );\r
+ \r
+ reset();\r
+ $("#sap").append(document.getElementById('form'));\r
+ ok( $("#sap>form").size() == 1, "Check for appending a form" ); // Bug #910\r
+ \r
});\r
\r
test("appendTo(String|Element|Array<Element>|jQuery)", function() {\r
});\r
\r
test("is(String)", function() {\r
- expect(22);\r
+ expect(26);\r
ok( $('#form').is('form'), 'Check for element: A form must be a form' );\r
ok( !$('#form').is('div'), 'Check for element: A form is not a div' );\r
ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );\r
ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );\r
ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );\r
ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );\r
+ \r
+ // test is() with comma-seperated expressions\r
+ ok( $('#en').is('[@lang="en"],[@lang="de"]'), 'Check for lang attribute: Expecte en or de' );\r
+ ok( $('#en').is('[@lang="de"],[@lang="en"]'), 'Check for lang attribute: Expecte en or de' );\r
+ ok( $('#en').is('[@lang="en"] , [@lang="de"]'), 'Check for lang attribute: Expecte en or de' );\r
+ ok( $('#en').is('[@lang="de"] , [@lang="en"]'), 'Check for lang attribute: Expecte en or de' );\r
});\r
\r
test("$.extend(Object, Object)", function() {\r
//console.log( close[0]); // it's the <a> and not a <span> element\r
return false;\r
}).click();\r
-});
\ No newline at end of file
+});\r