- ok( $("#foo").text("<div><b>Hello</b> cruel world!</div>")[0].innerHTML == "<div><b>Hello</b> cruel world!</div>", "Check escaped text" );
-
- // using contents will get comments regular, text, and comment nodes
- var j = $("#nonnodes").contents();
- j.text("hi!");
- equals( $(j[0]).text(), "hi!", "Check node,textnode,comment with text()" );
- equals( j[1].nodeValue, " there ", "Check node,textnode,comment with text()" );
- equals( j[2].nodeType, 8, "Check node,textnode,comment with text()" );
-});
-
-test("$.each(Object,Function)", function() {
- expect(8);
- $.each( [0,1,2], function(i, n){
- ok( i == n, "Check array iteration" );
- });
-
- $.each( [5,6,7], function(i, n){
- ok( i == n - 5, "Check array iteration" );
- });
-
- $.each( { name: "name", lang: "lang" }, function(i, n){
- ok( i == n, "Check object iteration" );
- });
-});
-
-test("$.prop", function() {
- expect(2);
- var handle = function() { return this.id };
- ok( $.prop($("#ap")[0], handle) == "ap", "Check with Function argument" );
- ok( $.prop($("#ap")[0], "value") == "value", "Check with value argument" );
-});
-
-test("$.className", function() {
- expect(6);
- var x = $("<p>Hi</p>")[0];
- var c = $.className;
- c.add(x, "hi");
- ok( x.className == "hi", "Check single added class" );
- c.add(x, "foo bar");
- ok( x.className == "hi foo bar", "Check more added classes" );
- c.remove(x);
- ok( x.className == "", "Remove all classes" );
- c.add(x, "hi foo bar");
- c.remove(x, "foo");
- ok( x.className == "hi bar", "Check removal of one class" );
- ok( c.has(x, "hi"), "Check has1" );
- ok( c.has(x, "bar"), "Check has2" );
-});
-
-test("remove()", function() {
- expect(6);
- $("#ap").children().remove();
- ok( $("#ap").text().length > 10, "Check text is not removed" );
- ok( $("#ap").children().length == 0, "Check remove" );
-
- reset();
- $("#ap").children().remove("a");
- ok( $("#ap").text().length > 10, "Check text is not removed" );
- ok( $("#ap").children().length == 1, "Check filtered remove" );
-
- // using contents will get comments regular, text, and comment nodes
- equals( $("#nonnodes").contents().length, 3, "Check node,textnode,comment remove works" );
- $("#nonnodes").contents().remove();
- equals( $("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works" );
-});
-
-test("empty()", function() {
- expect(3);
- ok( $("#ap").children().empty().text().length == 0, "Check text is removed" );
- ok( $("#ap").children().length == 4, "Check elements are not removed" );
-
- // using contents will get comments regular, text, and comment nodes
- var j = $("#nonnodes").contents();
- j.empty();
- equals( j.html(), "", "Check node,textnode,comment empty works" );
-});
-
-test("slice()", function() {
- expect(5);
- isSet( $("#ap a").slice(1,2), q("groups"), "slice(1,2)" );
- isSet( $("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" );
- isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );
- isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" );
-
- isSet( $("#ap a").eq(1), q("groups"), "eq(1)" );
-});
-
-test("map()", function() {
- expect(2);
-
- isSet(
- $("#ap").map(function(){
- return $(this).find("a").get();
- }),
- q("google", "groups", "anchor1", "mark"),
- "Array Map"
- );
-
- isSet(
- $("#ap > a").map(function(){
- return this.parentNode;
- }),
- q("ap","ap","ap"),
- "Single Map"
- );
-});
-
-test("contents()", function() {
- expect(12);
- equals( $("#ap").contents().length, 9, "Check element contents" );
- ok( $("#iframe").contents()[0], "Check existance of IFrame document" );
- var ibody = $("#loadediframe").contents()[0].body;
- ok( ibody, "Check existance of IFrame body" );
-
- equals( $("span", ibody).text(), "span text", "Find span in IFrame and check its text" );
-
- $(ibody).append("<div>init text</div>");
- equals( $("div", ibody).length, 2, "Check the original div and the new div are in IFrame" );
-
- equals( $("div:last", ibody).text(), "init text", "Add text to div in IFrame" );